Easy upgrading of Git on Mac (Lion)
I went through this process 6 months ago and of course in that time I've completely forgotten how to do it again. A return to Google and going through some trial-and-error brought it all back. So this post is as much reference for me as hopefully helping someone else.
I'm running Lion 10.7.5 but these steps should be version independent and will work with Snow Leopard, Mountain Lion etc.
Also, I'm sure there's many different (possibly better) ways to do this but this is the way that worked for me. Upgrading on the command line, building from source, using Homebrew are all options. But if you haven't got XCode installed or Homebrew this is a simple option.
I know this is an upgrade but the best way to do this is RTFM. Downloading the latest Graphical Git installer actually contains the simplest instructions!
Uninstall and reinstall Git
In the included README are the instructions to upgrade. Basically remove your existing Git, install the latest. If you have used any guides to setting up git config options these were retained after uninstall for me – so no need to worry about setting everything up again.
There's a shell script to uninstall Git. Again there's ways of doing this but here's the easiest:
- Copy 'uninstall.sh' to your desktop.
Open Terminal and type:
$ cd ~/Desktop
$ sh uninstall.sh
This gets you to desktop and uses the shell command to run the script. easy.
- Simply double click the installer to run
And that's it! Type
$ git --version and you should see you're running the latest version of Git (the same version as in the installer file name).
SSH remembering password
The reason I wanted to upgrade was for the new(er) option of remembering my username and password. I use Git on the command line (I just haven't got on with any GUI yet) but by default Git doesn't remember your password. When pushing and pulling to remote repos all day, having to retype your password is a real pain as I don't have the brain space to remember it.
By default Beanstalk uses SSH for repos now (nice feature) but you need at least Git 22.214.171.124 to remember credentials.
In short this is the command you need to remember your password for 24hours:
git config --global credential.helper 'cache --timeout=86400'
*Update 22nd July 2013
After the upgrade I had issues with Git asking for a password but then erroring with:
error: git-credential-osxkeychain died of signal 11
The answer came from Beanstalk's superb support.
you need to download a new version of git-credential-osxkeychain helper.
After downloading the file you need to set executable permissions on it:
chmod u+x git-credential-osxkeychain
And move it to it's path inside Git directory:
sudo mv git-credential-osxkeychain "$(dirname $(which git))/git-credential-osxkeychain"
And that fixed it. Basically this just downloads the git-credential-osxkeychain file and puts it in the right place. I have no idea why it went missing, got corrupted or wasn't included in the upgrade install but everything works as expected now.