Next: , Previous: , Up: Running Git   [Contents][Index]


4.7.4 Git Executable

When Magit calls Git, then it may do so using the absolute path to the git executable, or using just its name.

When running git locally and the system-type is windows-nt (any Windows version) or darwin (macOS) then magit-git-executable is set to an absolute path when Magit is loaded.

On Windows it is necessary to use an absolute path because Git comes with several wrapper scripts for the actual git binary, which are also placed on $PATH, and using one of these wrappers instead of the binary would degrade performance horribly. For some macOS users using just the name of the executable also performs horribly, so we avoid doing that on that platform as well. On other platforms, using just the name seems to work just fine.

Using an absolute path when running git on a remote machine over Tramp, would be problematic to use an absolute path that is suitable on the local machine, so a separate option is used to control the name or path that is used on remote machines.

User Option: magit-git-executable

The git executable used by Magit on the local host. This should be either the absolute path to the executable, or the string "git" to let Emacs find the executable itself, using the standard mechanism for doing such things.

User Option: magit-remote-git-executable

The git executable used by Magit on remote machines over Tramp. Normally this should be just the string "git". Consider customizing tramp-remote-path instead of this option.

If Emacs is unable to find the correct executable, then you can work around that by explicitly setting the value of one of these two options. Doing that should be considered a kludge; it is better to make sure that the order in exec-path or tramp-remote-path is correct.

Note that exec-path is set based on the value of the PATH environment variable that is in effect when Emacs is started. If you set PATH in your shell’s init files, then that only has an effect on Emacs if you start it from that shell (because the environment of a process is only passed to its child processes, not to arbitrary other processes). If that is not how you start Emacs, then the exec-path-from-shell package can help; though honestly I consider that a kludge too.

The command magit-debug-git-executable can be useful to find out where Emacs is searching for git.

M-x magit-debug-git-executable

This command displays a buffer with information about magit-git-executable and magit-remote-git-executable.

M-x magit-version

This command shows the currently used versions of Magit, Git, and Emacs in the echo area. Non-interactively this just returns the Magit version.


Next: Global Git Arguments, Previous: Running Git Manually, Up: Running Git   [Contents][Index]