I’m looking to install Git in a custom location different from the default
usr/local/git/bin/git directory that the package installer from the http://git-scm.com/ website installs to.
For example, I just tried copying the contents of
/Users/braitsch/my-git and updating my path variable to
/Users/braitsch/my-git/bin and now Git’s unhappy saying that it can’t find some of its commands such as
I also just tried setting
./git exec-path=/Users/braitsch/my-git/libexec/git-core but that doesn’t seem to be taking.
So my question is how can I setup a custom install of Git without the use of package managers or pre-built installers? I’d love to find a scenario that I could easily use on both Mac and Windows.
It looks like Git stash (and possibly other commands) will fail if you move the directory that gets installed at
usr/local/git via the package installer to another location. How can I get around this? I’m trying to run Git from a custom location but it appears this is not possible via the builds on the http://git-scm.com site?
What works fine for me (including
git stash) is to clone the git repository, e.g. with:
cd git clone git://github.com/gitster/git.git cd git make
(I had previously installed the build dependencies with
sudo apt-get build-dep git, which will work on a recent Debian-based distribution – otherwise if you get a build error you’ll just have to install git’s build dependencies with whatever mechanism you normally use.)
Then you can call this git with:
$ export GIT_EXEC_PATH=~/git/ $ ~/git/git --version git version 1.7.7.rc0.72.g4b5ea
… or using
~/git/git --exec-path=/home/mark/git instead of the environment variable.
You can move the built source tree to anywhere, and it still works, e.g.:
$ mv ~/git ~/tmp/ $ export GIT_EXEC_PATH=~/tmp/git/ $ ~/tmp/git/git --version git version 1.7.7.rc0.72.g4b5ea
Answered By – Mark Longair