使用GitHub管理iOS分布式项目开发
在我们iOS项目开发过程中, 我们的团队成员都是分散的、分布式,这个项目管理带来了挑战。Git是一个能够进行版本管理的软件,它是cvs和svn的未来。下面我根据我们的经验总结一些心得如下:
1、创建github账户
2、创建代码仓库
3、在xcode中添加项目到github
4、创建组织和团队
5、其他队员clone项目
创建github账户
你是可以根据自己的需要搭建git服务器,当然也可以使用github(https://github.com/)开源社区提供服务器,在这里可以有免费300M的空间使用,但是项目只能是共有的,如果是私有项目需要付费。进入https://github.com/plans注册你的github帐号。

为了能够使的你的电脑安全的访问github服务器,需要提供为你电脑进行SSH数字加密,大家可以参考http://help.github.com/mac-set-up-git/,生成公钥。然后点击<你帐号>->Edit Your Profile按钮->SSH key->Add SSH Key按钮。

把公钥文件用vi打开复制到key文本框中。
创建代码仓库
如果你是这个项目的管理员,你需要为你的项目创建代码仓库。登陆成功后输入https://github.com/repositories/new创建代码仓库如图。

在xcode中添加项目到github
在git技术中本地事实上也是需要有一个代码仓库保持远程的git服务器代码仓库保持一致的,即便不是团队开发一个项目,也应该创建本地的代码仓库,以便于自己管理软件代码。最简便的方法是在工程创建的时候就选择版本控制,在工程创建时候选择如下:

为了能够连接远程的代码仓库,需要做一些配置,打开的mac的终端输入命令:
$git config --global user.name"你的用户名" 注:可以不是你帐号
$git config --global user.email "你的email" 注:注册的帐号
$cd HelloWorld 注:创建的工程目录
$git init
$touch README
$git add README
$git commit -m 'first commit'
$git remote add origin git@github.com:<你的帐号>/HelloWorld.git
$git push –u origin master
如果你的mac 上面git客户端软件没有安装可以到如下地址下载安装。http://git-osx-installer.googlecode.com/files/git-1.7.9.4-intel-universal-snow-leopard.dmg。
在终端中执行完成命令后,回到xcode,保证所有的代码都已经commit了,然后在选择菜单:File->Source Control->push 弹出对话框。

点击Push按钮,这就会把你的工程推送到远程代码仓库了。这样回到github你就可以看到这些变化了。
创建组织和团队
你自己的帐号已经可以访问这个远程代码仓库了,但是这还不够你需要你的团队都能够访问这个远程代码仓库。首先,你需要在github中创建一个组织,点击 <你帐号>->Edit Your Profile按钮->Organizations->create new organization 按钮。如图所示输入组织名和组织email。

这样你回到Profile之后,就可以看到你所创建的组织了。

在Profile中选择组织->Members->team management。

进入团队管理画面点击“New Team”按钮,进入团队创建画面。

在name中输入团队的名字,在Members项目中输入已经在github注册的用户帐号,它是会自动识别的。在This team grants项目中选择“Push & Pull”,这可以使其他的团队成员能够也能推送他们的项目。在Repositories项目中选择远程的代码仓库名字。完成之后点击Save Team按钮保存。
其他队员clone项目
你已经把其他的团队成员添加进来了,他们还需要进入github设置一下。其他的成员登陆github后,选择Switch account context下拉框,如图所示。

选择组织名,进入组织画面选择团队名进入团队画面。

在团队画面中选择管理员帐号,进入管理员的画面。

这样在你的自己帐号下就可以看到管理员代码仓库了。

选择你需要的代码仓库,如图所示,点击Fork。

然后会弹出对话框

点击Fork to …按钮之后,这个test代码仓库的快照就添加到你自己的帐号下面的。

这些准备工作完成之后,你就可以把这个test远程代码仓库,利用团队成员的其他帐号clone到本地了。打开xcode在启动画面中选择Connect to repository

在下面画面中输入git@github.com:guandongsheng/test.git

如果能够连接到github这Next按钮可以被点击,如图所示开始clone了。


GitHub 教程系列文章: