使用 git 使 Xcode 4 停止自动暂存
我讨厌每当我在 Xcode 4 中进行更改时,它都会自动执行“Git add”命令。有办法让这种情况停止吗?
I hate it that whenever I make a change in Xcode 4 it automatically does a "Git add" command. Is there a way to make this stop?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
对于 Xcode 6 这不再是问题。访问首选项 ->源代码管理选项卡并关闭“自动添加和删除文件”复选框
For Xcode 6 this is not an issue anymore. Visit Preferences -> Source Control tab and turn off 'Add and remove files automatically' checkbox
我所做的就是通过命令行执行所有 git 交互。因为我无法让 Xcode 忽略我的项目受 git 控制的事实,因此我无法让 Xcode 停止为我创建的每个新文件执行 git add ,当我得到在命令行中,我做的第一件事是 git reset 来重置索引。这会撤消 Xcode 自动执行的所有烦人的 git add 操作。现在,我负责索引中的内容,因此我可以按照我想要的方式形成自己的提交。
What I do is perform all my git interaction through the command line. Since I can't get Xcode to ignore the fact that my project is under git control, and since therefore I can't get Xcode to stop doing
git add
for every new file I create, when I get to the command line the first thing I do isgit reset
to reset the index. This undoes all the annoyinggit add
stuff that Xcode did automatically. Now I'm in charge of what goes into the index and so I get to form my own commits the way I want.不。Xcode 4 的 git 集成“被破坏”了,因为他们试图为源代码控制提供一个统一的接口,无论后端是 git 还是 svn。这意味着它们仅支持功能的最低公分母。因此,不再使用索引(“暂存区域”)。无论您是否愿意,它总是会自动添加。
编辑:实际上,我不认为它会自动添加。我认为它总是
commit -a
。在命令行上查看 git status 会显示许多未暂存的新文件和修改过的文件。但我确信如果我使用 Xcode 进行承诺,它们最终都会出现在该提交中。No. Xcode 4's git integration is "broken" in that they tried to present a uniform interface to source control regardless of whether the back-end is git or svn. That means they're supporting only the lowest common denominator of functionality. As a result, use of the index (the "staging area") is out. It always does auto-adds no matter whether you want it to or not.
EDIT: Actually, I don't think it auto-adds. I think it always does
commit -a
. Looking atgit status
on the command line shows me many new and modified files that are NOT staged. But I'm sure if I committed with Xcode they'd all end up in that commit.对我来说,解决方案是这个 https://stackoverflow.com/a/6378745/1078859
TL;DR;从 xcode 的管理器中删除存储库
For me, the solution was this one https://stackoverflow.com/a/6378745/1078859
TL;DR; remove the repository from xcode's organizer
虽然问题标题显示 XCode 4,但即使在较新版本的 XCode 中,该问题也会出现在与此问题相关的许多搜索结果的顶部。这是解决新版本 XCode 的答案。在 XCode 6 中,您可以通过转到 XCode --> 来关闭版本控制。偏好设置 -->源代码控制选项卡并取消选中启用源代码控制。
While the question title says XCode 4 this question appears at the top for many search results related to this issue even in newer versions of XCode. Here is an answer that addresses newer versions of XCode. In XCode 6 you can turn off version control by going to XCode --> Preferences --> Source Control Tab and uncheck Enable Source Control.