Aaron Jensen
Aaron Jensen

Reputation: 26749

Configure Visual Studio to use system-installed Git.exe

Visual Studio 2017 ships with its own version of Git. Unfortunately, it doesn't have support for SSH and it doesn't include a root certificate for the issuer for SSL certificate protecting our repositories. So, whenever we try to clone, pull, or push, we get this error:

Error encountered while cloning the remote repository: Git failed with a fatal error. fatal: unable to access 'https://********/': SSL certificate problem: unable to get local issuer certificate

It looks like Visual Studio 2017 ships with its own version of Git. The latest version of Git, 2.12.2, fixes the issue above by adding support for looking in the Windows Certificate stores when validating SSL certificates. Is there anyway to configure Visual Studio to use the globally installed version of Git? Bonus points if the solution works across versions of Visual Studio.

Upvotes: 20

Views: 10211

Answers (5)

Asier Peña
Asier Peña

Reputation: 378

The Visual Studio installed Git version was causing issues on my side too, so I've replaced the entire folder where Visual Studio deploys its own version:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\

With the last 32-bits version downloaded from here. And after restarting the IDE the issues has gone, an option to change this from Visual Studio settings would be welcome, but at least this workaround works.

Visual Studio 2019 and above

The newer versions of Visual Studio uses directly the Git client installed on Windows, you can update it easily from command prompt using the following instructions.


Upvotes: 6

Axel.S
Axel.S

Reputation: 86

A good start is Bens answer (and edited by Patrick Mevzek) above, changing the external tools folder configuration. But unfortunately Visual Studio still uses its own implementation. You can verify that by setting environment variables like these:
GIT_TRACE with the path of the log file to write to as value and
GIT_TRACE_SETUP with the value 'true' (without the ').
Simply copying the global installation into the VS git folder has the bad side effect that the root configuration file is another than the global one. You might edit that VS config manually to include the global, but an update made that into a circular include, leading to git not working at all (even aside from VS). For me the solution is renaming (or deleting) that VS git folder, which forces VS to use the global installation. Sadly you have to rename/delete that folder after each VS update again. But at least a VS update doesn't mess up your global git installation and git uses always the same configuration. Would be nice, if microsoft would let us configure which installation to use instead of using some kind of hardcoded path.

Upvotes: 4

Ben
Ben

Reputation: 431

This may be a little bit late but just in case others come looking for this information and end up here, you can tell Visual Studio 2017/2019 to use the system installed version of Git by doing the following:

  1. Open up Visual Studio, click on the Tools menu item at the top.
  2. Select Options at the bottom of the list.
  3. In the search box for Visual Studio options search for Git
  4. Under the External Web Tools section, find the two entries that contain: $(DevEnDir)\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\cmd $(DevEnDir)\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\bin

External Tools Menu - Visual Studio 2017 Please note this screenshot was found on google because I don't have my computer on me for actual screenshots. So it may appear a bit different.

  1. Replace these with the location of your system installed version of git.

    Example of step five would be something like:

    C:\Program Files\Git\bin

    C:\Program Files\Git\mingw64\bin

  2. Finally, you will need to completely close down Visual Studio. I would recommend an actual restart just to play it safe because sometimes it doesn't see those changes even after re-opening Visual Studio.

Upvotes: 22

Joseph
Joseph

Reputation: 151

I have used a symbolic link to the system installed git folder location. 32-bit or 64 bit works. This way I did not have to have multiple git installations. The Problem with this method is, when Visual Studio is updated, it will break the installed git with its version, so the link has to be removed.

Not a perfect answer, I agree that it would be nice to have a way to use the system installed version or configure the embedded version.

Upvotes: 2

trh178
trh178

Reputation: 11648

I have not found an answer to your direct question in bold, but I am having similar SSL certificate issues, which I have solved with help from the following link:

Git in VS2017 with self-signed SSL

In short: Find the location of the certs folder that Visual Studio is using. It will be something like this:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\ssl\certs

I found this by going down to the /2017 directory and just searching from there.

Next: Open ca-bundle.crt and copy your full base64 encoded cert (including begin and end tags) in that file, and save.

Test with a fetch, or some such.

Hoping this solves at least half of your problem!

Upvotes: 1

Related Questions