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?
-
You have added git to the PATH environment variable? If you just made this change, did you restart Visual Studio? – Lasse V. Karlsen Sep 12 '19 at 10:14
-
1Sure git location is added to PATH, VS has been restarted, basically with command line I set **git config core.autocrlf false** but when committing with Visual Studio it still continues editing line endings – Grigoryants Artem Sep 12 '19 at 10:19
-
Please tell your VS version and how you proceeded to install git beforehand. It might be helpful. – MZanetti Sep 12 '19 at 10:37
-
`git config core.autocrlf false` should configure the repository you executed that command in, did you use Visual Studio in that repository, or did you use it in a different one? – Lasse V. Karlsen Sep 12 '19 at 10:54
-
Also note that Visual Studio by itself manages line endings in some cases. This may not be a git issue at all. – Lasse V. Karlsen Sep 12 '19 at 10:54
-
I configure core.autocrlf both globally and locally for the repo and use visual studio in target repository. Basically what I need is path to git.exe which Visual Studio is using for performing operations with git – Grigoryants Artem Sep 12 '19 at 12:58
-
Possible duplicate of [Visual Studio Git Source Control without Git for Windows or Github extension](https://stackoverflow.com/questions/40058906/visual-studio-git-source-control-without-git-for-windows-or-github-extension) – Lex Li Sep 15 '19 at 03:16
2 Answers
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
- 2,414
- 2
- 31
- 40
- 43,040
- 110
- 45
- 72
-
More info can be found in https://stackoverflow.com/questions/40058906/visual-studio-git-source-control-without-git-for-windows-or-github-extension – Lex Li Sep 15 '19 at 03:18
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).
- 541
- 4
- 9
-
1In my VS 2022 the path is `C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\cmd` – bb1950328 Feb 21 '22 at 06:34