简体   繁体   English

为现有Xcode 5项目添加本地存储库

[英]Add local repo for existing Xcode 5 Project

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 - >首选项 - >帐户 - >添加存储库 - >输入存储库地址来添加存储库:

So what would I input here for a local repository (on my iMac) I'm wanting to work on? 那么我在这里输入的本地存储库(在我的iMac上)我想要继续工作?

Cheers. 干杯。

I would do this from the command line. 我会从命令行执行此操作。

  1. Close Xcode.app 关闭Xcode.app
  2. Open Terminal.app 打开Terminal.app
  3. $ cd /path/to/project/dir
  4. $ git init .
  5. Create a .gitignore file to ignore some of the Xcode and output files that you don't want tracked (see below). 创建一个.gitignore文件,忽略一些您不想跟踪的Xcode和输出文件(见下文)。
  6. $ git add .gitignore
  7. $ git add .
  8. $ 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 bare repo 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项目时,它将为源代码使用做好准备。

Apple's official solution is here. Apple的官方解决方案就在这里。 See "Use Git to Manage an Unmanaged Workspace Directory on a Development Mac" 请参阅“使用Git管理开发Mac上的非托管工作区目录”

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 . 您可以通过在项目的顶级文件夹中打开终端,然后键入git init来创建新的repo。 Your repo is now created and will automatically be recognized by Xcode. 您的仓库现已创建,并将自动被Xcode识别。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM