Skip to content

Git Executable Detection

Michael Hutchison edited this page Aug 22, 2019 · 2 revisions

As Git Graph requires a Git executable to be present on the users computer to run underlying the Git commands, when Visual Studio Code is opened the extension must find it. The following steps are performed by the extension to determine the absolute path of the Git executable:

  1. If Visual Studio Code & Git Graph have previously been opened, the extension will check to see if the last known Git executable still exists. If it does, it will use it. This speeds up the extension start up time.
  2. If the user has manually set the path and file name of a Git executable in the Visual Studio Code setting git.path, the extension checks to see if it is a valid Git executable. If it is, it will use it.
  3. Depending on the platform returned by Node.js:
    • darwin (Mac & Linux): Runs the command which git to determine the absolute path of the Git executable.
    • win32 (Windows): Checks the following directories for the Git executable (matching the Visual Studio Code behaviour), and returns as soon as the first match is found:
      • process.env['ProgramW6432'] + '\Git\cmd\git.exe
      • process.env['ProgramFiles(x86)'] + '\Git\cmd\git.exe
      • process.env['ProgramFiles'] + '\Git\cmd\git.exe
      • process.env['LocalAppData'] + '\Git\cmd\git.exe
      • All directories in process.env['PATH']

Notes

  • If you change git.path, Git Graph will only use it if there is no known Git executable, or the last known Git executable no longer exists.
  • If you use git.path, make sure:
    • It is the path and file name of a Git executable (e.g. C:\Program Files\Git\bin\git.exe).
    • Backslashes are correctly escaped for JSON (e.g. "git.path": "C:\\Program Files\\Git\\bin\\git.exe")
  • If you have multiple versions of Git executables on your computer, you can check to see which Git executable is being used by the extension in the log (which is shown in a Visual Studio Code Output Channel).
    • For example: [2019-08-23 09:23:28.691] Using C:\Program Files\Git\cmd\git.exe (version: 2.17.1.windows.2)

General Information:

Release Information:

Contributing Information:

If you have any questions about Git Graph, please chat with us on Discord!

Clone this wiki locally