Git Reference ยท Environment Variables
GIT_EXEC_PATH
Reference for GIT_EXEC_PATH and git --exec-path: the directory of Git's built-in helpers and subcommands, how git-foo lookup works, and custom subcommands.
git is a dispatcher. When you type git foo, it looks for a program called git-foo and runs it. Built-in commands are compiled into the main binary, but the helper programs (git-remote-https, git-upload-pack, git-http-backend, scripts such as git-sh-setup) live in a separate directory, often called libexec/git-core. That directory is Git's exec path.
GIT_EXEC_PATH overrides it, and git --exec-path prints (or sets) it. Normal use never needs this: the location is compiled in or found relative to the executable. It matters when you relocate an installation, test a freshly built Git without installing it, or debug "remote helper not found" errors.
git --exec-path # print the current exec path GIT_EXEC_PATH=/opt/git/libexec/git-core git fetch git --exec-path=/opt/git/libexec/git-core status
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
git --exec-path[=<path>] <command> GIT_EXEC_PATH=<path> git <command> git --exec-path # print only
| Name | Description |
|---|---|
GIT_EXEC_PATH |
Directory searched first for git-* programs. Passed on to child processes. |
--exec-path[=<path>] |
With a value, sets the exec path for this invocation; without one, prints it and exits. |
--html-path, --man-path, --info-path |
Print the locations of the HTML, man and info documentation. |
Lookup order for git <name>: built-in commands first; then git-<name> in the exec path; then git-<name> anywhere on PATH; then aliases (a GIT_TRACE run shows Git trying git-st before it expands the alias st). Aliases can never replace a built-in. If nothing matches, Git prints '<name>' is not a git command and may suggest similar names.
Edge cases: built-in commands such as status, log and rev-parse do not need the exec path, which is why they still work with a wrong value. Network helpers (git-remote-https, git-http-backend) and git-upload-pack for ssh remotes do, so a bad path shows up as remote helper 'https' aborted or git: 'remote-https' is not a git command.
Usage notes
- Custom subcommands: any executable named
git-<name>onPATHbecomesgit <name>, andgit <name> --helplooks for a man pagegit-<name>. This is howgit-lfs,git-flowand many team tools integrate. - Running Git from a build directory: set
GIT_EXEC_PATHto the source tree (wheremakeleaves the helpers), or use thebin-wrappersscripts from the Git build, which set it for you. - Relocatable installs: Git finds its exec path relative to the real location of the executable when built with a runtime prefix (the default on Windows). Moving the whole folder keeps it working; moving only
gitdoes not. - Security: a writable directory early on
PATHor inGIT_EXEC_PATHlets anyone drop in a fakegit-status-style helper that runs when you invoke remote operations. Treat it like any other executable search path. - Hooks and scripts get the variable set by Git itself, so a script calling
gitlater uses the same helpers as the parent. git help -alists commands found in the exec path and onPATH, grouped by category.
Related
git help,git var,GIT_TRACEand friends, Remote helpers- Lessons: Getting help, Aliases