【问题标题】:Unable to create a snapshot in XCode 4.5.1 after update the ~/.gitconfig option [push.default] to "simple"将 ~/.gitconfig 选项 [push.default] 更新为“simple”后,无法在 XCode 4.5.1 中创建快照
【发布时间】:2012-10-22 01:09:03
【问题描述】:

我能够在 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 repo,而是使用快照作为备份我的代码的一种方式。我认为 XCode 的快照中的 git 有一些技巧,我无法弄清楚。现在我想知道是否有人可以告诉我如何在 XCode 中重新启用快照(而不是更改 .gitconfig [push.default] 选项)?

【问题讨论】:

  • 我创建了这个脚本让 Xcode 使用你在 /usr/local/bin 中的本地安装的 Git。看看这个。 gist.github.com/4659915

标签: xcode git snapshot


【解决方案1】:

我设法解决了我自己的问题。相关详情见Question 10449374

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

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

所以当我:

  1. 通过自制软件安装了新版本的 git,
  2. 在 ~/.gitconfig 中更新新的 push.default 选项,
  3. 想在 Xcode 项目中创建快照

那我就会遇到我上面描述的问题。

这是我的解决方案:

  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

我对@9​​87654325@做了同样的事情

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 选项。

【讨论】:

    【解决方案2】:

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

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

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

    虽然它对用户不太友好......无论如何,您可能想检查一下:Setting environment variables in OS X?。但请注意,全局覆盖 $HOME 可能不是是个好主意。

    【讨论】:

    • 但是我没有设置git控制的项目,很奇怪吧?
    • 我不认为快照功能使用了 git,但无论是否启用 git,它都可能有不同的行为。所以我猜Xcode会使用git(Xcode自带的git)在拍快照之前做一些检查,当git失败的时候会报错。
    • 是的,所以我将我自己的 git 版本链接到 XCode 中,然后它与快照配合得很好。
    猜你喜欢
    • 1970-01-01
    • 2011-09-25
    • 2014-09-06
    • 2012-08-12
    • 2010-12-13
    • 2013-01-27
    • 1970-01-01
    • 1970-01-01
    • 2020-12-16
    相关资源
    最近更新 更多