Tonight I found myself with the need to host my own git repository on one of my own servers. This time, for the first time, it was a server I don’t actually have administrative access to and it was one where git wasn’t pre-installed. Thankfully, with a bit of help from Blue Static, I built and installed git from scratch in literally ten minutes. Here’s the short version of how I did it, which may even be generic enough that you can copy and paste this into a
bash shell prompt on your server to do the same thing:
cd ~/ # change to home directory test -d ~/src || mkdir ~/src # if there isn't already a ~/src directory, create it cd ~/src # then change to that directory curl -O http://www.kernel.org/pub/software/scm/git/git-188.8.131.52.tar.gz # download tar -xvzf git-184.108.40.206.tar.gz # and extract the git source code cd git-220.127.116.11 # change to the source code directory ./configure --prefix=$HOME # configure build to install into $HOME make # do the build make install # move the built binaries to the right places echo "export PATH=\$PATH:$HOME/bin" >> ~/.bashrc # make sure non-interactive shells can find git
Of special note is the last line, which sets up the necessary
$PATH specifically for non-interactive
bash shells for use with
git-pull. With out that, you’ll run into the infamous “bash: git-receive-pack: command not found” error.