添加 pod 文件并推送。如何撤消?如何在 Xcode 和 github 中使用 gitignore?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34230191/
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
Added pod files and pushed. How to undo? how to use gitignore in Xcode & github?
提问by skypirate
This is a two part question: 1) I have added committed and pushed all pod files to github. Is there a way I can remove them and not push them again to github?
这是一个由两部分组成的问题:1)我已添加提交并将所有 pod 文件推送到 github。有没有办法可以删除它们而不将它们再次推送到 github?
2) I know gitignore can help, but I don't know how to use it. Can anyone please walk me through the process of using gitignore?
2) 我知道 gitignore 可以提供帮助,但我不知道如何使用它。任何人都可以引导我完成使用 gitignore 的过程吗?
so I think what I can do is, get the project from github, add gitignore, and then push again. is that correct?
所以我觉得我能做的就是,从github上获取项目,添加gitignore,然后再push。那是对的吗?
Please help, new to github & Xcode.
请帮助,github 和 Xcode 新手。
回答by Maximelc
That's correct, you need to add the Pods directory to your .gitignore
没错,您需要将 Pods 目录添加到您的.gitignore
1) Remove your files from your github repository:
1) 从 github 存储库中删除文件:
git rm -r Pods/
git rm -r Pods/
and don't forget to commit and push
并且不要忘记提交和推送
2) Create a gitignore file:
2)创建一个gitignore文件:
- Open terminal and go through your project folderwhere the .git folderis located
- Type
touch .gitignore
- Type
echo "Pods/" > .gitignore
- 打开终端,并通过你的项目文件夹,其中git的文件夹所在
- 类型
touch .gitignore
- 类型
echo "Pods/" > .gitignore
More informations : here
更多信息:这里
回答by Rishabh Saxena
This is what Cocoapodsofficial documentation has to say.
这就是Cocoapods官方文档要说的。
Whether or not you check in your Pods folder is up to you, as workflows vary from project to project.
It recommends that you keep the Podsdirectory under source control, and don't add it to your .gitignore. But ultimately this decision is up to you:
是否签入 Pods 文件夹取决于您,因为工作流程因项目而异。
它建议您将Pods目录置于源代码控制之下,并且不要将其添加到您的 .gitignore 中。但最终这个决定取决于你:
Benefits of checking in the Pods directory:
签入 Pods 目录的好处:
- After cloning the repo, the project can immediately build and run, even without having CocoaPods installed on the machine. There is no need to run pod install, and no Internet connection is necessary.
- The Pod artifacts (code/libraries) are always available, even if the source of a Pod (e.g. GitHub) were to go down.
- The Pod artifacts are guaranteed to be identical to those in the original installation after cloning the repo.
- 克隆 repo 后,项目可以立即构建和运行,即使机器上没有安装 CocoaPods。不需要运行 pod install,也不需要 Internet 连接。
- Pod 工件(代码/库)始终可用,即使 Pod 的源(例如 GitHub)已关闭。
- 克隆 repo 后,Pod 工件保证与原始安装中的工件相同。
Benefits of ignoring the Pods directory:
忽略 Pods 目录的好处:
1.The source control repo will be smaller and take up less space. As long as the sources (e.g. GitHub) for all Pods are available, CocoaPods is generally able to recreate the same installation. (Technically there is no guarantee that running pod install will fetch and recreate identical artifacts when not using a commit SHA in the Podfile. This is especially true when using zip files in the Podfile.)
1.源代码控制repo将更小,占用更少的空间。只要所有 Pod 的源(例如 GitHub)都可用,CocoaPods 通常能够重新创建相同的安装。(从技术上讲,当不在 Podfile 中使用提交 SHA 时,无法保证运行 pod install 会获取并重新创建相同的工件。在 Podfile 中使用 zip 文件时尤其如此。)
2.There won't be any conflicts to deal with when performing source control operations, such as merging branches with different Pod versions.
2.在进行源码控制操作时不会有任何冲突需要处理,例如合并不同Pod版本的分支。
Whether or not you check in the Pods directory, the Podfileand Podfile.lockshould always be kept under version control.
无论您是否检查 Pods 目录,Podfile和Podfile.lock都应始终处于版本控制之下。
Reference Link:Cocoapods Official Documentation
参考链接:Cocoapods 官方文档