Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up a custom Git installation

Tags:

git

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 usr/local/git to /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 git -stash.

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 for you guys is how would you 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 & Windows. Thanks in advance.

-Update-

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. Does anyone have any suggestions on how to 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?

like image 221
braitsch Avatar asked Oct 04 '11 15:10

braitsch


2 Answers

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
like image 111
Mark Longair Avatar answered Oct 11 '22 09:10

Mark Longair


I would just re-build it from source. Grab a tarball from http://git-scm.com/ then build it using ./configure --prefix=/path/to/my-git/.

Edit: I'm not sure off the top of my head how to make a relocatable git installation, but if you start by building it with a particular, unique, prefix, installing it, then grepping through the installed files for the prefix (ie, grep -R my-git /path/to/my-git/), that would likely be a good starting point.

like image 20
David Wolever Avatar answered Oct 11 '22 08:10

David Wolever