我能够在 XCode 4.5.1 中为我的项目创建快照。但现在同一个项目一直告诉我:
Unable to create a snapshot
error: Malformed value for push.default: simple
error: Must be one of nothing, matching, tracking or current.
fatal: bad config file line 21 in /Users/oppih/.gitconfig
我记得今天早些时候将另一个项目推送到 github 时,系统提示我这个警告:
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
所以我用谷歌搜索了一下,不久前发现了这个问题:13148066 ,解决了,我用git config --global push.default simple
因为“这是一种更直观的行为,这就是默认值更改为这个的原因。”
我认为我的 XCode 问题一定与这个 git 选项更新有关。
回到 XCode,我没有选择在我的 XCode 项目中设置 git 存储库,而是使用快照作为备份代码的方式。我认为 XCode 的快照中的 git 有一些技巧,我无法弄清楚。现在我想知道是否有人可以告诉我如何在 XCode 中重新启用快照(同时不更改 .gitconfig [push.default] 选项)?
最佳答案
我设法解决了我自己的问题。参见Question 10449374相关详情。
这种情况下的主要问题是:Xcode 只是在/Applications/Xcode.app/Contents/Developer/usr/bin 中安装(以及命令行工具)自己的 git 版本。
不知何故,Xcode 还对其使用自己版本的工具(例如 git)进行了硬编码。而且(我不知道为什么)Xcode 的“快照”功能与 git 有一定的集成。
所以当我:
- 通过 homebrew 安装了新版本的 git,
- 更新 ~/.gitconfig 中的新 push.default 选项,
- 想要在 Xcode 项目中创建快照
然后我就会遇到我上面描述的问题。
这是我的解决方案:
切换到 Xcode 目录:
cd/Applications/Xcode.app/Contents/Developer/usr/bin
像这样重命名 Xcode 的 git:
sudo mv ./git ./git-xcode-usr-bin
链接我自己的 git,它是通过 homebrew 安装的:
sudo ln -s/usr/local/bin/git ./git
我对 /usr/bin/git
做了同样的事情
sudo mv /usr/bin/git /usr/bin/git-xcode-usr-bin
sudo ln -s /usr/local/bin/git /usr/bin/git
这实际上会链接 /usr/local/Cellar/git/1.8.0/bin/git
(因为我目前使用 git 1.8.0)
这有点棘手,如果我将来升级自制的 git,我必须更新链接。它确实与 Xcode 的快照和新的 Push.default 选项配合得很好。
关于xcode - 将 ~/.gitconfig 选项 [push.default] 更新为 "simple"后,无法在 XCode 4.5.1 中创建快照,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13177203/