切换到工作区并在 Xcode 中添加 CocoaPods 后提交到 git?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22291456/
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
Commit to git after switching to workspace and adding CocoaPods in Xcode?
提问by Kent
I've just added CocoaPods to my current project in Xcode 5. Of course, CocoaPods created a workspace and I've launched the workspace in Xcode. I see both my project and the Pods project in the workspace.
我刚刚在 Xcode 5 中将 CocoaPods 添加到我当前的项目中。当然,CocoaPods 创建了一个工作区,我已经在 Xcode 中启动了该工作区。我在工作区中同时看到了我的项目和 Pods 项目。
My project has been under source control (local git + remote Bitbucket repository) since day one. Now I want to commit and add the Pod stuff but I think that my repo is too deep in the workspace--when I try to commit (and I've tried various commits to get the Pod stuff to take) it always errors out.
我的项目从第一天起就受到源代码控制(本地 git + 远程 Bitbucket 存储库)。现在我想提交并添加 Pod 的东西,但我认为我的 repo 在工作区中太深了——当我尝试提交时(我已经尝试了各种提交来获取 Pod 的东西),它总是出错。
How can I add my Pods to my repo? Do I have to delete the old repo and create a new one (git init) at the Workspace level? (I sure hope not because I'm not that great with git and I have a lot of historical commits in my repo already.)
如何将我的 Pod 添加到我的存储库中?我是否必须删除旧存储库并在工作区级别创建一个新存储库 (git init)?(我当然希望不是,因为我对 git 不是那么好,而且我的 repo 中已经有很多历史提交了。)
回答by SwiftArchitect
git add .
git 添加。
From the directory enclosing your Xcode project, simply execute a git add .
. Documentation here.
从包含 Xcode 项目的目录中,只需执行一个git add .
. 文档在这里。
Explanation
解释
You likely had the following hierarchy prior pod init
:
您之前可能有以下层次结构pod init
:
In all likelihood, your git
setup starts at the directory enclosing .xcodeproj
.
很可能,您的git
设置从包含.xcodeproj
.
After pod install
, the hierarchy did not change. You merely have more files at the same level:
之后pod install
,层次结构没有改变。您只是在同一级别拥有更多文件:
The .xcworkspace
is next to .xcodeproj
, not above. You are free to execute
在.xcworkspace
旁边.xcodeproj
,而不是上面。你可以自由执行
git add .
...followed by
...其次是
git commit -m "message"
...assuming that .gitignore
is set up properly, and wether or not you prefer to commit the Pods
directory.
...假设.gitignore
设置正确,无论您是否喜欢提交Pods
目录。