Pascal Berger
Pascal Berger

Reputation: 4342

Using LFS with Visual Studio 2017

I wan't to use Visual Studio 2017 (15.5) together with a Git repository which tracks some files with Git LFS.

I already have Git 2.15, which contains Git LFS, installed on the machine.

I've Visual Studio 2017 installed with only the following workloads and without the Git component since it already is available on the machine:

--add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --add Microsoft.VisualStudio.Workload.NetCoreTools --add Microsoft.VisualStudio.Component.Wcf.Tooling

Visual Studio fails now to checkout branches from the repository since it cannot find Git LFS.

I assume this is because git-lfs.exe is not available on the path, and Visual Studio has its own Git instance in c:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\bin\.

If I additionally install the standalone git-lfs installer, which makes git-lfs available on the path, checkout works on some machines but not on other (haven't found out what's the difference, maybe installation order or if it was a new installation or update of Visual Studio).

If I remove the c:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\ folder everything works fine in Visual Studio, as it does use the Git version available from the path.

My questions are:

  1. What is the supposed way to have Git LFS support in Visual Studio?
  2. Is there a way to have Visual Studio using the Git Version on the path instead of installing its own instance
  3. Does Visual Studio expect git-lfs on the path or should it also work with Git LFS installed through the bundled installer in recent versions of Git for Windows.

Upvotes: 3

Views: 9255

Answers (1)

Pascal Berger
Pascal Berger

Reputation: 4342

To get Git LFS working with Visual Studio 2017 (15.5.2) it requires Git LFS installed with the standalone Git-LFS installer. If Git LFS is installed with the Git for Windows distribution git-lfs.exe is not available on the PATH, and since Visual Studio has its own instance of Git, LFS functionality won't work.

It is also important to have Git LFS early in the path otherwise it won't be passed to Git by Visual Studio as the PATH passed to the Git instance run by Visual Studio is limited in the length. For example installing Git LFS after Visual Studio often ends with git-lfs.exe too late in the PATH.

Upvotes: 13

Related Questions