Unable to create a snapshot in XCode 4.5.1 after update the ~/.gitconfig option [push.default] to “simple”

牧云@^-^@ 提交于 2019-11-29 08:31:28
oppih

I managed to solve my own problem. See it in Question 10449374 for the related details.

The main problem in this case is that: Xcode just install (along with the Command Line Tools) its own version of git in /Applications/Xcode.app/Contents/Developer/usr/bin .

And somehow, Xcode also hard coded it would use its own version of tools (such as git). And (I don't know why) Xcode's "snapshot" feature has some integration with git.

So when I:

  1. installed a new version of git via homebrew,
  2. update the new push.default option in ~/.gitconfig ,
  3. want to create a snapshot in an Xcode project

Then I will encounter the problem I described above.

Here's my solution:

  1. change into the Xcode directory:

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

  2. rename the Xcode's git like this:

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

  3. link my own git which is installed through homebrew:

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

And I did the same thing with /usr/bin/git

sudo mv /usr/bin/git /usr/bin/git-xcode-usr-bin
sudo ln -s /usr/local/bin/git /usr/bin/git

This will acctually link /usr/local/Cellar/git/1.8.0/bin/git (because I'm use git 1.8.0 at the present)

It's a little tricky, and I have to update the link if I upgrade the homebrewed git in the future. And it really works fine with Xcode's snapshot and the new push.default option.

Rox Dorentus

Well, you may try specifying another .gitconfig file for Xcode by method provided in this answer: How can I specify custom global gitconfig path?.

For example, after created ~/.xcode_home as the new $HOME for Xcode app, you can use the following shell script to launch Xcode:

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

It is not quite user friendly though… Any way, you may want to check this: Setting environment variables in OS X?. But be warned, overwriting $HOME globally might not be a good idea.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!