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

简介:

USING GIT IN XCODE

http://www.cimgf.com/2013/12/10/using-git-in-xcode/

Git has become a very popular version control system in iOS and Mac development. Git comes with a set of command line tools to check status, commit changes, view logs, make and merge branches, and coordinate commits with a remote repository.  There are a number of desktop apps that can perform these functions, including Xcode.  When I ask other iOS and Mac developers how they interact with Git, most say they use the command line or a separate desktop app like Tower.  I find very few developers use Xcode for even some basic Git tasks, and many developers are not aware of the Git support Xcode offers.

Git已经成为了非常流行的版本控制工具。Git是一系列的命令行工具,用以检查状态、提交更改、查看日志、创建和对比分支、并将源码远程提交到服务器上。有很多很多工具都能做这项事情,Xcode自身也有Git的功能。我问了很多iOS以及Mac的开发者他们是怎么使用Git的,大部分都说他们使用命令行工具,或者是一个独立的app例如Tower。我发现很少有人使用Xcode自带的Git来进行最基本的一些操作,还有,很多开发者根本就不知道Xcode自身就支持Git,提供了Git的相关服务。

For my own workflow, I like to minimize the number of tools used and number of switches between apps needed to complete a task.  So, I decided to attempt to use Xcode exclusively to interact with Git and share my results.  So far I have been pleasantly surprised at what all Xcode can do with Git. If you have not taken a look at Xcode’s support for Git, you may be surprised how much you can accomplish.

在我的大部分工程当中,我喜欢用最少的工具来控制不同版本的app。所以,我决定尝试一下使用Xcode自带的Git以及分享我的经验。至今为止,我发现Xcode可以用Git做到很多相当不错的功能。如果你还没有用过Xcode自带的Git,当你在使用它的时候也许会被惊艳到。

This article assumes basic familiarity with Xcode and Git, and describes Git functionality present in Xcode version 4.6.2.

这篇文章假定你熟悉Xcode以及Git的使用,文章中的Git的功能描述是在Xcode的4.6.2版本上进行的。

 

NEW GIT PROJECT SETUP IN XCODE

Since Git is a distributed version control system, a repository can be created locally when starting a project, or on a remote server and then cloned.  Xcode can handle both situations.

When creating a new Xcode project, you can include a local git repository by checking the “Create local git repository for this project” option.  Xcode will initialize the repository and perform an initial commit with the template files for you.

自从发布了Git这个版本控制工具之后,一个工程拷贝既可以在本地创建,也可以通过从服务器的拷贝来完成。Xcode能处理这两种情形。

当在创建一个新的Xcode工程项目时,你可以在选项 Create local git repository for this project 来包含一个本地的git拷贝。Xcode会初始化这个拷贝并获取到文件供你使用。

If you are sharing your project with a team or just want a backup of your project on another machine, you can set up a remote copy of the repository.  The typical way this is done is to create an empty repository on a git service like GitHub or Bitbucket.  Once the repository is available, return to Xcode and open the Organizer. Select Repositories to view all the version control repositories that Xcode is aware of, and find the new project repository.  Select Remotes for the new project, add then click the Add Remote button.

如果你是团队开发,或者仅仅只想在另外的一台电脑上获取一个拷贝,你可以创建一个远程的拷贝。常用的方式是在Github或者Bitbucket上创建一个空的拷贝。一旦这个拷贝可以被你使用了,回到Xcode后打开Organizer。选择 Repositories 后可以查看所有你可以操作的版本,然后找到创建新版本那一项,然后点击 Add Remote 按钮添加。

Xcode will present a dialog to add the remote. You can follow the default naming standard for a git remote and give it the name “origin”, or you use a custom name.  Then specify the remote URL for the repository, which will be provided by Bitbucket.

Xcode会显示一个提示框来添加远程版本,你可以根据默认值给个名字抑或自己起个名字。然后,你提供一个远程版本的URL地址,这个地址是由远程服务器提供的(比如Github或者Bitbucket)。

If the remote repository is private and requires authentication, you can enter it after the remote is added.  Select the remote in the Organizer list, and an authentication interface will appear below the list.

如果这个远程的版本是私有的需要你提供验证信息,你可以在添加完了之后输入验证信息。你在Organizer选择这个远程版本,一个提示框会提示你输入信息的。

Once the remote is added and authentication provided, the master branch needs to be pushed to it.  Return to the Xcode project window.  From the Xcode menu, select File | Source Code | Push… Xcode will present a sheet which will allow you to select a remote to push to, and a branch to push.  Note that Xcode has checked with the remote repository, and indicates that the master branch will be created in the remote repository with the push.

一旦远程的版本被添加了,你也输入了验证信息,你就需要选择要push的主分支了。回到Xcode工程当中,在Xcode菜单中,选择 File | Source Code | Push… Xcode 后会出现提示框,让你选择一个版本来作为你push所用。

Once the push is complete, the remote repository is available for updates and for other users.

一旦push操作成功了,你就可以使用这个远程版本用来提交代码了。

目录
相关文章
|
开发工具 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下找。
3077 0
|
开发工具 git iOS开发
Mac 下为 XCode 创建 Git 服务器 - 简单得不能再简单
Mac 下为 XCode 创建 Git 服务器 - 简单得不能再简单 太阳火神的美丽人生 (http://blog.csdn.net/opengl_es) 本文遵循“署名-非商业用途-保持一致”创作公用协议 转载请保留此句:太阳火神的美丽人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS、Android、Html5、Arduino、pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作。
1054 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.
1238 0
|
开发工具 iOS开发 git
iOS开发那些事-Git在Xcode中的配置与使用
<p>很多Git命令都是在命令行下运行的,命令行下管理Git有很多优点不用多说。但最大的缺点是要求用户记住这些命令。因此Git图形界面还是很受一些用户欢迎的,其中Xcode作为集成开发环境工具,也提供了一定Git图形界面功能。但是要想在Xcode中使用Git管理工程代码还想需要进行一些配置,然后才能使用。</p> <p>如果我们是使用Xcode 4创建的一个iOS工程,在终端的命令行中提交代码
1528 0
|
开发工具 iOS开发 git
iOS开发那些事-Git在Xcode中的配置与使用常见问题总结
<p>书接上回提出的Git在Xcode中的配置与使用常见问题4个问题</p> <p><span id="more-255"></span></p> <p>问题1,如何在Xcode中创建代码库,并添加和提交代码到代码库?</p> <p>问题2,如何在Xcode中提交推送给远程服务器代码库?</p> <p>问题3,如何在Xcode中克隆远程服务器代码库到本地?</p> <p>问题4,如何使用Xco
1864 0

相关实验场景

更多