每当我尝试 git pull 或 push 时,Xcode 都会说“未提交的更改”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11173261/
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
Xcode says "Uncommitted Changes" Whenever I try to git pull or push
提问by Muhammad Hassan Nasr
I am using git in my projects, whenever I try to pull from Xcode I get "Uncommitted Changes" and it prevents me from pulling/pushing. I try to commit and find one file with extension *.xcuserstate, this file is modified whenever I open/scroll into any project file in Xcode. That leaves me no option but to do a single commit that contains that file, which fill the git commit logs with meaningless commits.
我在我的项目中使用 git,每当我尝试从 Xcode 中提取时,我都会收到“未提交的更改”,它阻止我拉/推。我尝试提交并找到一个扩展名为 *.xcuserstate 的文件,每当我在 Xcode 中打开/滚动到任何项目文件时都会修改该文件。这让我别无选择,只能做一个包含该文件的提交,用无意义的提交填充 git commit 日志。
Is this there is a way to stop this behavior?
有没有办法阻止这种行为?
I tried to put *.xcuserstate and xcuserdata into git ignore but that caused Xcode to crash every time I try to pull.
我试图将 *.xcuserstate 和 xcuserdata 放入 git ignore 但这导致每次我尝试拉取时 Xcode 都崩溃。
This happens with Xcode 4.2 and 4.3
这发生在 Xcode 4.2 和 4.3
回答by Greg Hewgill
Normally you don't want to put the *.xcuserstate
and *.xcuserdata
files into your Git repository. These files aren't really part of your project, but are just a place where Xcode stores its local information that is helpful when reloading your project.
通常,您不想将*.xcuserstate
和*.xcuserdata
文件放入 Git 存储库。这些文件实际上并不是您项目的一部分,而只是 Xcode 存储其本地信息的地方,这在重新加载您的项目时很有帮助。
You can fix this by using:
您可以使用以下方法解决此问题:
git rm --cached *.xcuserstate *.xcuserdata
and then committing the result. This will remove those files from the repository without removing them from your working directory.
然后提交结果。这将从存储库中删除这些文件,而不会从您的工作目录中删除它们。
回答by Usman
If this is a settings file which is different for every developer, you probably don't need to version control it, just remove it from Git.
如果这是每个开发人员都不同的设置文件,您可能不需要对其进行版本控制,只需将其从 Git 中删除即可。
If that is not an option, you can Git Stash Save
your changes before pulling and Git Stash pop
to apply them again.
如果这不是一个选项,您可以Git Stash Save
在拉取之前进行更改并Git Stash pop
再次应用它们。