2

I'm currently trying to install multiple Git versions on OS X for testing purposes. After downloading the OS X installer bundle from git-scm.com (which installs to /usr/local/git), I move it to a different location, e.g. ~/git-1.7.11.1 or ~/git-1.8.1. Unfortunately, Git does not like this move:

$ ~/git-1.7.11.1/bin/git fetch
fatal: Unable to find remote helper for 'https'

or even worse:

$ ~/git-1.7.11.1/bin/git pull
git: 'pull' is not a git command. See 'git --help'.

Did you mean this?
        shell

When I set the path, it also does not work:

$ export PATH=~/git-1.7.11.1/bin:$PATH
$ which git
/Users/xxx/git-1.7.11.1/bin/git
$ git pull
git: 'pull' is not a git command. See 'git --help'.

Did you mean this?
        shell

Is there anything I need to change in the Git bundles, too, to make them portable (aka running at each location)?

Mot
  • 28,248
  • 23
  • 84
  • 121
  • 1
    You could probably install multiple `git` versions from source, with the `--prefix=/path/to/install/dir`. See [this question](http://stackoverflow.com/questions/5892695/can-i-use-git-without-installing). If you've installed to `/usr/bin/local`, then moved the installed files, you should check that `~/git-1.7.11.1/bin` is in your `$PATH` so that `git` can find the various `git` binary files. – simont Apr 03 '13 at 12:42
  • 1
    I want to create *portable* Git installations which are not bound to a certain location. – Mot Apr 03 '13 at 16:34

2 Answers2

3

The git-scm installer does appear to install everything in /usr/local/git (inferred by looking at the uninstall.sh file in the git-scm download). Therefore, renaming the git directory should not be a problem. What you need to do is augment your path as such:

PATH=$PATH:/usr/local/git-1.7.11.1/bin

so that git and all its helper programs can be found.

Note that this approach won't work if you try to call multiple git versions from the same shell; all the versions will get their helper programs from the first directory in PATH.

[edit] You will also need to set the environment variable GIT_EXEC_PATH. Use

git --exec-path

to learn what it currently is and then use a new one with:

git --exec-path=<...git-1.7.11.1/...>

or by defining GIT_EXEC_PATH.

Also it appears that the build path is built into the git executable which may indicate that git expects its supporting files in a default location.

ebg@ebg(147)$ strings git | grep usr
/usr/local/git
/usr/local/bin:/usr/bin:/bin

ebg@ebg(148)$ strings /usr/bin/git | grep usr
/Applications/Xcode.app/Contents/Developer/usr
/usr/local/bin:/usr/bin:/bin

So, use GIT_EXEC_PATH. See the GIT Man Page for more info.

GoZoner
  • 67,920
  • 20
  • 95
  • 145
  • If you build from source, you can also run without installing or setting GIT_EXEC_PATH by calling bin-wrappers/git as described in [INSTALL](https://github.com/git/git/blob/v1.7.1/INSTALL#L41-L45). – Glen K – Glen K Jun 28 '18 at 21:58
2

I needed to set GIT_EXEC_PATH:

$ ~/git-1.7.11.1/bin/git pull
git: 'pull' is not a git command. See 'git --help'.

Did you mean this?
        shell
$ export GIT_EXEC_PATH=~/git-1.7.11.1/libexec/git-core/
$ ~/git-1.7.11.1/bin/git pull
Password for 'https://xxx': 
Mot
  • 28,248
  • 23
  • 84
  • 121