将〜/ .gitconfig选项[push.default]更新为“simple”后,无法在XCode 4.5.1中创建快照

时间:2012-11-01 12:35:31

标签: xcode git snapshot

我能够在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 ealier时,我收到了这个警告:

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

所以我用Google搜索并在不久前找到了这个问题:13148066,并解决了问题,我使用git config --global push.default simple因为"这是一个更直观的行为,这就是为什么默认值已更改为此。"

我认为我的XCode问题必须与此git选项更新有关。

回到XCode,我没有选择在我的XCode项目中设置git repo,而是使用快照作为备份我的代码的方法。我认为在XCode的快照中使用git有一些技巧,我无法弄明白。现在我想知道是否有人可以告诉我如何在XCode中重新启用快照(而不是更改.gitconfig [push.default]选项)?

2 个答案:

答案 0 :(得分:3)

我设法解决了自己的问题。请参阅Question 10449374中的相关详细信息。

这种情况下的主要问题是:Xcode只是在/Applications/Xcode.app/Contents/Developer/usr/bin中安装(连同命令行工具)自己的git版本。

不知何故,Xcode也硬编码它将使用自己的工具版本(如git)。而且(我不知道为什么)Xcode的“快照”功能与git有一些集成。

所以当我:

  1. 通过自制软件安装了新版本的git,
  2. 更新〜/ .gitconfig中的新push.default选项,
  3. 想在Xcode项目中创建快照
  4. 然后我会遇到上面描述的问题。

    这是我的解决方案:

    1. 切换到Xcode目录:

      cd /Applications/Xcode.app/Contents/Developer/usr/bin

    2. 重命名Xcode的git:

      sudo mv ./git ./git-xcode-usr-bin

    3. 链接我自己的git,它是通过自制程序安装的:

      sudo ln -s /usr/local/bin/git ./git

    4. 我用/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选项,它确实可以正常工作。

答案 1 :(得分:1)

好吧,您可以尝试通过此答案中提供的方法为Xcode指定另一个.gitconfig文件:How can I specify custom global gitconfig path?

例如,在创建了〜/ .xcode_home作为Xcode应用程序的新$ HOME之后,您可以使用以下shell脚本来启动Xcode:

HOME=$HOME/.xcode_home open "$(xcode-select --print-path)/../.."

虽然用户不太友好......但是,您可能需要查看此内容:Setting environment variables in OS X?。但要注意,全球覆盖$ HOME可能是个好主意。