How to install Git
On Windows:
Install msysgit
There are several downloads:
- Git: Use this unless you specifically need one of the other options below.
- PortableGit: Use this if you want to run Git on a PC without installing on that PC (e.g. running Git from a USB drive)
- msysGit: Use this if you want to develop Git itself. If you just want to use Git for your source code, but don't want to edit Git's source code, you don't need this.
This also installs a Cygwin bash shell, so you can use the git
in a nicer shell (than cmd.exe), and also includes git-gui (accessible via git gui
command, or the Start > All Programs > Git
menu)
Mac OS X
Use the git-osx-installer, or you can also install from source
Via a package manager
Install git
using your native package manager. For example, on Debian (or Ubuntu):
apt-get install git-core
Or on Mac OS X, via MacPorts:
sudo port install git-core+bash_completion+doc
…or fink:
fink install git
…or Homebrew:
brew install git
On Red Hat based distributions, such as Fedora:
yum install git
In Cygwin the Git package can be found under the "devel" section
From source (Mac OS X/Linux/BSD/etc.)
In Mac OS X, if you have the Developer Tools installed, you can compile Git from source very easily. Download the latest version of Git as a .tar.bz
or .tar.gz
from http://git-scm.com/, and extract it (double click in Finder)
On Linux/BSD/etc. it should be much the same. For example, in Debian (and Ubuntu), you need to install the build-essential
package via apt
.
Then in a Terminal, cd
to where you extracted the files (Running cd ~/Downloads/git*/
should work), and then run..
./configure && make && sudo make install
This will install Git into the default place (/usr/local
- so git
will be in /usr/local/bin/git
)
It will prompt you to enter your password (for sudo
), this is so it can write to the /usr/local/
directory, which can only be accessed by the "root" user so sudo is required!
If you with to install it somewhere separate (so Git's files aren't mixed in with other tools), use --prefix
with the configure command:
./configure --prefix=/usr/local/gitpath
make
sudo make install
This will install the git
binary into /usr/local/bin/gitpath/bin/git
- so you don't have to type that every time you, you should add into your $PATH
by adding the following line into your ~/.profile
:
export PATH="${PATH}:/usr/local/bin/gitpath/bin/"
If you do not have sudo access, you can use --prefix=/Users/myusername/bin
and install into your home directory. Remember to add ~/bin/
to $PATH
The script x-git-update-to-latest-version automates a lot of this:
This script updates my local clone of the git repo (localy at ~/work/track/git
), and then configures, installs (at /usr/local/git
-git describe
) and updates the /usr/local/git
symlink.
This way, I can have /usr/local/git/bin
in my PATH
and I'm always using the latest version.
The latest version of this script also installs the man pages. You need to tweak your MANPATH
to include the /usr/local/git/share/man
directory.