[翻译] USING GIT IN XCODE [6] 在XCODE中使用GIT[6]

简介:

USING GIT IN XCODE

KEEPING IN SYNC WITH REMOTE REPOSITORIES

As you make changes in your local working copy you will want to keep them in sync with the remote repository.  Xcode offers support for pulling from and pushing to a remote repository, and for tracking remote branches.

There are two ways to pull from a remote repository. The first is from the project window.  Select File | Source Control | Pull from the Xcode menu when viewing a project window.   If there are no uncommitted changes in the working copy, Xcode will present a dialog to select which remote and branch to pull from. (Note that a pull can be completed using command line Git when changes are present, but Xcode will not pull with uncommitted changes in the working directory.)

也许你想在本地备份上修改代码的时候,同步到服务器端当中。Xcode提供了pulling一级pushing操作,以及追踪远程版本。

有两种方式来从服务器端pull代码。第一种方式就是直接在工程的window菜单中操作。选择File | Source Control | Pull from the Xcode menu,如果本地没有进行修改的操作,Xcode将会提供一个菜单供你选择从哪一个分支上pull代码。

Alternatively, the Pull button from the Organizer Repositories view can be used when a working copy is selected.

另外一种方法是,这个Pull的按钮可以从Organizer Repositories中点选。

If a conflict is detected on the pull, Xcode will present the merge viewer to resolve the conflict.  Just like resolving a conflict between branches, the merge viewer can be used to select which change(s) should be kept and in what order they should be if both are desired. If you do not want to resolve the conflict, click the Cancel button in the merge view and the pull will not take place.

如果在pull过程中检测到了冲突,Xcode会显示出merge工具来帮你解决冲突。如果不想解决冲突,点击取消按钮也行。

If the conflict is resolved, the working copy will be modified and will need to be committed and pushed.

To push changes to the remote repository, select File | Source Control | Push from the Xcode menu when viewing a project window.

如果冲突被解决了,你又写了代码并想提交代码。

你可以通过File | Source Control | Push from the Xcode menu来提交代码。

A branch can also be pushed to the remote repository.  Xcode will detect if the branch does not yet exist in the remote, and will indicate if the branch will be created by a push.

当然你也可以提交代码到一个新的分支中去,Xcode会检测有没有你想要的那个分支,如果没有,他会帮你创建那个分支。

Once a branch has been created on the remote repository, other working copies can track that branch.   To track a branch, visit Organizer, Repositories, and select Remotes for the project repository.  Expand the remote name to see the available branches.  (In my testing, I was not able to get Xcode to refresh remote branches without restarting Xcode).

一旦一个分支在服务器上被创建了,其他的版本都能够跟踪那个分支。要跟踪一个分支,访问Organizer,Repositories,选择Remotes for the project repository,然后选择展开的那个分支的名字。

Select a remote branch and click the Track Branch button at the bottom of the view.  This will pull down the branch from the remote repository to the local repository, will allow you to switch to the branch in Xcode, and will allow pulls and pushes to take place from it.

选择了那个分支后点击Track Branch按钮,你就会从服务器更新到那个分支的代码,你可以随意的在不同的分支中切换来切换去。

SUMMARY

As we have seen here, Xcode has very usable support for common Git tasks, including setting up Git for a new project, cloning an existing project, handling modifications and commits, viewing history, using branches, and pushing and pulling from remote repositories.  Xcode does not have direct support for stashing, tags, or more advanced topics like rebasing or submodules.  However, all of the items that Xcode does not support can be performed using the command line tools or using a third party tool.  In my day to day work with a distributed development team, I am frequently able to perform all of my Git tasks in Xcode, and only rarely need to resort to the command line.  Take a second look at Xcode’s Git support if you have not done so before, and give feedback to the Xcode team so they can keep enhancing and improving Git support in Xcode.

在这里,我们可以看出,Xcode支持Git很到位,包括创建一个Git项目、拷贝一个Git项目,操作修改,提交代码,浏览历史记录,使用版本分支以及从服务器进行push或者pull操作。Xcode并没有直接支持诸如隐藏、标记、或者一些更高级更热门的功能。然而,那些更高级的功能都能够通过命令行工具或者是第三方工具来实现。在我日复一日的分布式团队工作当中,我频繁的使用者Xcode自带的git工具,只有极少数情况会用到命令行。如果您没用过Xcode自带的git工具,你可以试验一把,并给Xcode团队反馈使用上不方便的地方,帮助Xcode提升Git的使用便利性^_^。

目录
相关文章
|
开发工具 iOS开发 git
mac安装git后,在终端里运行git命令,系统提示需要安装Xcode问题解决
直接下载git for mac 安装包,https://git-scm.com/download/mac 安装完后,git的默认安装目录是:/usr/local/git 但是使用 which git 命令后,发现git的目录是:/usr/bin/git 意思是我们安装的git-xxx.dmg默认路径在/usr/local/git,但Mac系统执行git命令却去/usr/bin/git下找。
3069 0
|
开发工具 git iOS开发
Mac 下为 XCode 创建 Git 服务器 - 简单得不能再简单
Mac 下为 XCode 创建 Git 服务器 - 简单得不能再简单 太阳火神的美丽人生 (http://blog.csdn.net/opengl_es) 本文遵循“署名-非商业用途-保持一致”创作公用协议 转载请保留此句:太阳火神的美丽人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS、Android、Html5、Arduino、pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作。
1052 0
|
开发工具 iOS开发 git
Using GIT In Xcode
Using GIT In Xcode Post by Joe Keeley on December 10, 2013 Git has become a very popular version control system in iOS and Mac development.
1237 0
|
开发工具 iOS开发 git
iOS开发那些事-Git在Xcode中的配置与使用
<p>很多Git命令都是在命令行下运行的,命令行下管理Git有很多优点不用多说。但最大的缺点是要求用户记住这些命令。因此Git图形界面还是很受一些用户欢迎的,其中Xcode作为集成开发环境工具,也提供了一定Git图形界面功能。但是要想在Xcode中使用Git管理工程代码还想需要进行一些配置,然后才能使用。</p> <p>如果我们是使用Xcode 4创建的一个iOS工程,在终端的命令行中提交代码
1528 0

相关实验场景

更多