Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git push.default setting after installing xcode

Tags:

git

xcode

macos

I don't know for sure that this was caused by my xcode installation, but that's the only major change that happened on my computer before git stopped working. I also found some info on github that suggested this might be the problem. Anyway, whenever I try to pull, clone, or push, I get this message:

error: Malformed value for push.default: simple
error: Must be one of nothing, matching, tracking or current.
fatal: bad config file line 3 in /Users/mbc/.gitconfig

If I run git --version, I get this: git version 1.7.10.2 (Apple Git-33)

I tried installing the latest version, but even though the installer claimed success, git --version has not changed.

So maybe git is installed in two different places? which git gives me /usr/bin/git but I'm not sure where git is supposed to be, so this is not particularly helpful yet.

Any ideas?

like image 734
user1895572 Avatar asked Oct 06 '22 17:10

user1895572


1 Answers

This behaviour can indeed be explained by the installation of Xcode. In fact, I had very similar behaviour by upgrading to Mavericks, because that apparently reinstalls or updates Xcode.

What happened is this : you had a fully working version of git installed, which you had configured to use simple for its push.default. Xcode gets installed (or updated), and brings with it another, outdated version of git, which does not yet know of the option simple for push.default. When you type git on the command line, your PATH is searched for a binary to execute. The Xcode-git is found on your path first, before your more recent version of git. Installing git again doesn't help, because it is still installed in the same location, and that location is on your path after the Xcode git.

One possible solution, as already suggested by silent1mezzo, is to do this in terminal :

sudo rm -rf /usr/bin/git
sudo ln -s /usr/local/git/bin/git /usr/bin/git

However, if you then upgrade Xcode and it reinstalls its own git again, it will overwrite that link we just created. This is probably what caused it to break on my upgrade to Mavericks.

Another option is to put /usr/local/git/bin in your path before /usr/bin. You could do this by putting a line like this in your .bash_profile:

export PATH=/usr/local/git/bin:$PATH

(if you don't have a file .bash_profile yet, just create it in your home directory)

This will cause the more recent version of git to be the one that is found first when your path is searched. One detail : terminals that are already open when you put that line in .bash_profile won't get the new behaviour right away - you could run source ~/.bash_profile to get them to the new behaviour, or just close them and start them again.

like image 146
frederikvs Avatar answered Oct 10 '22 02:10

frederikvs