Grigoryants Artem
Grigoryants Artem

Reputation: 1621

Where is Visual Studio's git.exe location?

I'm configuring git through command line but changes seems doesn't apply to Visual Studio's git actions, so I'm wondering perhaps VS uses another git instance with other configs, where can I find which git.exe is getting used by VS?

Upvotes: 32

Views: 30157

Answers (4)

neuronz
neuronz

Reputation: 41

Visual Studio 2022 stores default git configuration data in the

C:\Users\<user>\.gitconfig

file that can be overridden in each Project's

...\.git\config

file. For example, to get my alternative diff tool working after upgrading to VS 2022 I needed to do the following:

Execute the "git config" commands from the Visual Studio 2022 Command-Line tool:

git config --global diff.tool ExamDiffPro
git config --global difftool.ExamDiffPro.path "C:/Program Files/ExamDiff Pro/ExamDiff.exe"

This added the following lines to the

C:\Users\<user>\.gitconfig

file:

[diff]
    tool = ExamDiffPro
[difftool "ExamDiffPro"]
    cmd = "'C:/Program Files/ExamDiff Pro/ExamDiff.exe'" -e "$LOCAL" "$REMOTE"

Remove any overriding [diff] settings from the local Project's

...\.git\config

file. For example, remove:

[diff]
    tool = <some other tool or the default Visual Studio tool>

Upvotes: 1

Erik Toft
Erik Toft

Reputation: 51

Parts of the path are variable depending on your OS version and version of VS.

C:\{Program Files or Program Files (x86)}\Microsoft Visual Studio\{VS Version Year - 2017 - 2019 - 2022 - etc.\{VS Category - Community - Professional - Enterprise - etc.}\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\cmd

For example, my path is...

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\cmd

Upvotes: 1

Adrian Mole
Adrian Mole

Reputation: 51815

Visual Studio gets the location of the various git tools from the config file in the .git folder, for example, in lines like this:

[difftool "vsdiffmerge"]
    cmd = \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer\\vsdiffmerge.exe\" \"$LOCAL\" \"$REMOTE\" //t
    keepBackup = false

Other than that, the only place I can find a git.exe on my PC is here:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\bin\git.exe

For Visual Studio 2022 (which runs in native 64 bit mode), the location is:

C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw64\bin\git.exe

Upvotes: 38

WSLUser
WSLUser

Reputation: 631

VS2019 appears to have a near full-blown install of Git for Windows hidden within it's installation. The only thing that appears to be stripped out of it is Mintty. So you can set the GIT_PATH env var as well as GIT_SSH just like in Git for Windows and use it via CLI as easily as using git in Visual Studio.

You can find the path here: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\cmd

and here: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\bin

Set your path to the first one (this is what Git for Windows uses).

Upvotes: 13

Related Questions