码云链接:https://git.oschina.net
码云帮助文档:https://my.oschina.net/zxs/blog/142544
博客中的zhuzhuxia,均是我使用的自定义名,同时也是我电脑的用户名
第一步:项目创建


1、创建项目的时候主要需要注意项目名+语言+是否公开选项这三项
至于添加gitignore与否由你自己决定,这个选项主要是为了实现屏蔽某一些你不想上传的后缀文件选项,比如.xcodeproj这样的
2、创建项目后添加成员,项目成员管理->添加项目成员

这样就能进行协同开发了
第二步:生成SSH密钥
1、终端命令:ssh-keygen -t rsa -C "你注册时的邮箱"
如果注册成功会显示
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/你的电脑名称/.ssh/id_rsa):zhuzhuxia
2、自定义文件名:如你所见:Enter file in which to save the key (/Users/你的电脑名称/.ssh/id_rsa): 是在提示你输入要保存的文件名称,方便你查找,我此处的名称是zhuzhuxia,所以应该会生成zhuzhuxia.pub和zhuzhuxia这两个文件
3、输入密码Enter passphrase (empty for no passphrase):
4、确认密码:Enter same passphrase again:
成功的话会提示你
Your identification has been saved in zhuzhuxia.
Your public key has been saved in zhuzhuxia.pub.
The key fingerprint is:
剩余的就不方便展示了,你懂得
5、为了确认已经生成了pub,可以直接在终端输入指令cat zhuzhuxia.pub
,然后辅助ssh-rsa直至结尾,这一段便是公钥的内容
也可以自己却Macintosh HD->用户->zhuzhuxia,然后就能看见zhuzhuxia和zhuzhuxia.pub两个文件了,直接用文本工具打开zhuzhuxia.pub文件,然后复制zhuzhuxia.pub的全部内容

第三步:粘贴公钥
粘贴公钥分两种,
1、一种是在项目中粘贴公钥(管理->部署公钥管理->添加公钥),如果在项目中粘贴公钥就是该公钥只对该项目有效,比如你所具有的push,pull权限,便只能在该项目中使用

2、第二种是对用户粘贴公钥,我一般选这个

选中用户名右上角的编辑按钮->SSH公钥->粘贴

第四步:添加并连接
1、添加:ssh-add ~/zhuzhuxia
2、输入密码:Enter passphrase for /Users/zhuzhuxia/zhuzhuxia:
成功后会提示:Identity added: /Users/zhuzhuxia/zhuzhuxia (/Users/zhuzhuxia/zhuzhuxia)
3、连接:ssh -T git@git.oschina.net
成功后会提示:Welcome to Git@OSC, 猪猪侠在这!
如果是第一次添加应该还会提示你
Are you sure you want to continue connecting (yes/no)?
输入yes就好了
第五步:配置个人信息
1、设置用户名:git config --global user.name "zhuzhuxia"
2、设置邮箱:git config --global user.email +你注册时的邮箱
第六步:项目操作
做完以上的工作后,终于可以回到Xcode了,😄😄😄
1、拷贝远程项目地址:

找到项目->点击克隆/下载按钮,拷贝HTTPS地址
2、打开Xcode,点击Check Out an existing project

3、粘贴链接

4、输入账号和密码

5、创建项目源文件,并把创建的源文件放置在导入本地的git库中,并且你创建时不必勾选Creaete Git repository on
选项,

6、提交源文件

commit源文件的所有东西,然后删除源文件,重新Check Out,否则pull会出问题,并且以后在项目中不在上传.xcodeproj,包括它里边的xcworkspace、pbxproj和xcuserdata
至于文件后面的M,I这些字母代表的意思与svn基本通用,前面的svn介绍应该也有涉及
网友评论