USING GIT IN XCODE

USING BRANCHES

Branches can be a very effective tool to isolate new features or experiments in code.  Xcode has pretty good support for branches, but it is not shown in the project view.  The first method you can use to commit code to a branch is to select “Commit to Branch…” instead of “Commit X Files” from the commit view.

分支控制是一个非常有用的隔离新特性的一种开发方式。Xcode对于分支支持得很好,但是没在视图中显示出来。你可以在 “Commit to Branch…”中选择向那个分支提交,而不是在“Commit X Files”上提交。

Xcode will ask you to select a branch to commit to, or will allow you to create a new branch.

Xcode会问你要向哪一个分支上提交代码,抑或你自己再创建一个分支出来。

Once you have committed to a branch from master, you will be automatically switched to that branch.  You can continue making changes and commits to the branch.  So how do you know what branch you are on in Xcode, or get back to the master branch, or switch to another branch?  Visit the Repositories in the Organizer, find the repository for your project, and select the working copy.

一旦你从主分支向子分支提交了代码,你将会自动切换到子分支当中去。你可以继续进行修改提交到这个子分支中。所以,你怎么知道你是在Xcode中的哪一个分支呢?你可以通过访问Organizer中的Repositories,在那里你可以发现你的分支。

To see what branch you are currently on, look in the upper right hand corner of the Repository view.

为了查看当前是在哪一个分支上,查看右上角的view。

To switch back to master or to another branch, click the “Switch Branch” button in the lower right hand corner.  Select another branch, and your Xcode project workspace will be updated to reflect the current contents of the other branch.

为了切换到主分支或者是其他分支中去,点击右下角的按钮“Switch Branch”。选择另外一个分支,然后,你的Xcode project workspace会自动的切换到另外一个分支中的内容。

When you are ready to merge a branch, switch to the branch you want to merge into first from the Organizer.  Then switch back to the project view,  and select File | Source Control | Merger from the Xcode menu.  Xcode will ask which branch you would like to merge into your current branch.

当你准备比较两个分支的代码时,先在Organizer中切换到你要比对的分支当中去。然后回到工程中,选择File | Source Control | Merger from the Xcode menu,Xcode会询问你要与哪一个分支比较代码。

Xcode will then present a merge view, which will allow you to review each difference between the current branch and merge branch.

Xcode之后会显示出一个比较的view,允许你检查两个分支的不同之处。

Use the sliders to selectively include or exclude changes from the branch in the merge.

If there is a conflict in the merge, the merge view will highlight the conflict in the merge view with red and a question mark in the center.

使用sliders来选择或者取消修改过的代码。

如果存在着冲突,比较代码的工具会高亮冲突的代码,然后在中间的地方用红色的带有疑问的标记显示着。

The merge view will offer four choices for resolving the conflict: keep both changes, placing the left before right, keep only the left changes, keep only the right changes, and keep both changes, placing the right before left.  In addition the code can be directly edited in the merge view.

比较代码的工具会提供4种选择解决冲突:保持两个改变,使用左边的变化,使用右边的变化,另外,你可以直接在merge上修改代码。

最新文章

  1. MATLAB的PLOT函数线型设置及横坐标为字符串的代码实例
  2. Microsoft Visual Studio 开发的C++程序软件发布相关事宜
  3. 数论 - Pairs(数字对)
  4. HDU 5145 NPY and girls 莫队+逆元
  5. IDEA UML类图插件
  6. revel + swagger 文档也能互动啦
  7. VS的一部分快捷键
  8. java 防止sql注入的方法(非原创)
  9. Latex 去掉行号
  10. element-tree-grid(表格树)的使用
  11. vs2017安装pygame,vs2017安装python第三方包
  12. 深入剖析Kubernetes学习笔记:开篇词(00)
  13. 学习WPF
  14. linux mysql 定时备份
  15. C++ enum的使用
  16. html5制作导航条
  17. 安卓工作室 android studio文件和代码模板,以及汉化出错问题
  18. APScheduler 浅析
  19. python中常用的内建模块
  20. bzoj 2213: [Poi2011]Difference

热门文章

  1. 解决nginx访问问题connect() to 127.0.0.1:8080 failed (13: Permission denied) while connecting to upstream,
  2. C#(Winform)中button的Enable=false和visible的区别
  3. Leetcode 762. Prime Number of Set Bits in Binary Representation
  4. java内存中的对象
  5. [BZOJ 5072]小A的树
  6. ubuntu 常见错误--Could not get lock /var/lib/dpkg/lock 问题修改
  7. Supervisord安装和配置
  8. BZOJ4475 [Jsoi2015]子集选取
  9. 【PyQt5 学习记录】005:QMainWindow 及状态栏、菜单栏和工具栏
  10. JS(微信小程序)处理银行卡号