为现有的 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 04:08:24  来源:igfitidea点击:

Add local repo for existing Xcode 5 Project

iosxcodegitxcode5

提问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.

我会从命令行执行此操作。

  1. Close Xcode.app
  2. Open Terminal.app
  3. $ cd /path/to/project/dir
  4. $ git init .
  5. Create a .gitignorefile to ignore some of the Xcode and output files that you don't want tracked (see below).
  6. $ git add .gitignore
  7. $ git add .
  8. $ git commit -a -m Initial.
  1. 关闭 Xcode.app
  2. 打开 Terminal.app
  3. $ cd /path/to/project/dir
  4. $ git init .
  5. 创建一个.gitignore文件以忽略一些您不想跟踪的 Xcode 和输出文件(见下文)。
  6. $ git add .gitignore
  7. $ git add .
  8. $ git commit -a -m Initial.

Sample (but incomplete) .gitignorefile:

示例(但不完整).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

Apple's official solution is here.See "Use Git to Manage an Unmanaged Workspace Directory on a Development Mac"

Apple 的官方解决方案在这里。请参阅“使用 Git 在开发 Mac 上管理非托管工作区目录”

回答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 识别。