为现有的 Xcode 5 项目添加本地存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19495141/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Add local repo for existing Xcode 5 Project
提问by SamoanProgrammer
I've running through a Xcode 5 tutorial and want to make some significant changes, but want to make this Xcode 5 project into a repository.
我已经浏览了 Xcode 5 教程并希望进行一些重大更改,但希望将此 Xcode 5 项目放入存储库。
I've done some reading and you can add a repository by going to Xcode -> Preferences -> Accounts -> Add Respository -> Enter the repository address:
我已经做了一些阅读,您可以通过转到 Xcode -> Preferences -> Accounts -> Add Respository -> 输入存储库地址来添加存储库:
So what would I input here for a local repository (on my iMac) I'm wanting to work on?
那么我会在这里为我想要处理的本地存储库(在我的 iMac 上)输入什么?
Cheers.
干杯。
回答by trojanfoe
I would do this from the command line.
我会从命令行执行此操作。
- Close
Xcode.app
- Open
Terminal.app
$ cd /path/to/project/dir
$ git init .
- Create a
.gitignore
file to ignore some of the Xcode and output files that you don't want tracked (see below). $ git add .gitignore
$ git add .
$ git commit -a -m Initial.
- 关闭
Xcode.app
- 打开
Terminal.app
$ cd /path/to/project/dir
$ git init .
- 创建一个
.gitignore
文件以忽略一些您不想跟踪的 Xcode 和输出文件(见下文)。 $ git add .gitignore
$ git add .
$ git commit -a -m Initial.
Sample (but incomplete) .gitignore
file:
示例(但不完整).gitignore
文件:
build/
*/xcuserdata/
And most likely you'll want to add a remote tracking repo, perhaps on github or bitbucket (once a barerepo has been created there):
并且很可能您想添加一个远程跟踪存储库,可能在 github 或 bitbucket 上(一旦在那里创建了一个裸存储库):
$ git remote add origin https://bitbucket.org/yourname/yourrepo.git
$ git push -u origin --all
$ git push -u origin --tags
When you open the Xcode project next time it will be ready for Source Code use.
当您下次打开 Xcode 项目时,它将准备好供源代码使用。
回答by Justicle
回答by Scott Berrevoets
That's only for already existing repos that are stored somewhere outside of your project directory. You can create a new repo by opening the terminal in the top-level folder of your project, and then typing git init
. Your repo is now created and will automatically be recognized by Xcode.
这仅适用于存储在项目目录之外某处的现有存储库。您可以通过打开项目顶级文件夹中的终端,然后键入git init
. 您的存储库现已创建并会自动被 Xcode 识别。