Skip to content
Tutorials Center
My learning

Topics

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.

Terminal
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

Bash Print the exec path and see which commands need 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.

Bash Your own subcommand: anything called git-something on PATH

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

Terminal
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> on PATH becomes git <name>, and git <name> --help looks for a man page git-<name>. This is how git-lfs, git-flow and many team tools integrate.
  • Running Git from a build directory: set GIT_EXEC_PATH to the source tree (where make leaves the helpers), or use the bin-wrappers scripts 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 git does not.
  • Security: a writable directory early on PATH or in GIT_EXEC_PATH lets anyone drop in a fake git-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 git later uses the same helpers as the parent.
  • git help -a lists commands found in the exec path and on PATH, grouped by category.