Failed to create a snapshot in Xcode 4.5.1 after updating the ~ / .gitconfig [push.default] option to "simple"

I managed to create a snapshot for my project in Xcode 4.5.1. But now the same project just tells me that:

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 

I remember that when I clicked another project on github ealier, I was prompted with this warning:

 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 

So, I searched for it and found this question not so long ago: 13148066 , and it was installed, I use git config --global push.default simple , because "this is more intuitive behavior, so the default value changes to it".

I think that my problem with Xcode should have a connection to this update of the Git options.

Returning to Xcode, I did not choose to configure the Git repository in my Xcode project, but used a snapshot as a way to back up my code. I think there is a trick with Git in the Xcode snapshot, I cannot figure it out. Now I'm wondering, can someone tell me how to re-enable the snapshot in Xcode (without changing the .gitconfig [push.default] parameter)?

+2
git xcode snapshot
Nov 01 '12 at 12:35
source share
2 answers

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

The main problem in this case is that: Xcode simply installs (along with the command line tools) its own version of git in /Applications/Xcode.app/Contents/Developer/usr/bin.

And somehow Xcode was also hardcoded, it would use its own version of tools (e.g. git). And (I don’t know why) Xcode "snapshot" has some integration with git.

So when I:

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

Then I will encounter the problem described above.

Here is my solution:

  • go to the Xcode directory:

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

  • rename Xcode git as follows:

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

  • bundle my own git that installs via homebrew:

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

And I did the same 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 link the link /usr/local/Cellar/git/1.8.0/bin/git (because I'm currently using git 1.8.0)

This is a bit complicated, and I have to update the link if I will update homebrewed git in the future. And it really works great with the Xcode snapshot and the new push.default option.

+3
Nov 13 '12 at 15:06
source share

Well, you can try specifying a different .gitconfig file for Xcode using the method provided in this answer: How to specify a custom global gitconfig path? .

For example, after creating ~ / .xcode_home as a new $ HOME application for Xcode, you can use the following shell script to run Xcode:

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

He's not exactly a user friendly though ... You can check this out anyway: Setting environment variables in OS X? . But be careful when rewriting $ HOME everywhere, it may not be a good idea.

+1
Nov 11 '12 at 14:45
source share



All Articles