5

I use git lfs to store the large files of my git repo. I then try to build this repo with hosted agents. My build is pretty simple. It has a single task: Execute PowerShell. In the invoked script, the first thing that I want to do is to fetch my lfs dependencies. I therefore have the following in my script:

& git lfs fetch

Unfortunately, my build fails with the following error:

2016-03-04T19:49:05.7021988Z ##[error]git: 'lfs' is not a git command. See 'git --help'.
2016-03-04T19:49:05.7031986Z ##[error]Did you mean this?
2016-03-04T19:49:05.7041987Z ##[error]  flow

Since I can't install anything on hosted agents, how am I supposed to have git lfs available?

EDIT In this issue, I am not talking about git lfs authentication problems as described here. I am strictly talking about the issue of calling git lfs.

Once you are able to call git lfs, look at this answer to solve the authentication problem.

Community
  • 1
  • 1
mabead
  • 2,171
  • 2
  • 27
  • 42

4 Answers4

3

Git LFS is now supported by default on the Hosted Build Controller. But you do need to enable it in your get sources step.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
2

You get this error message because git-lfs isn't installed on Hosted Build Agent by default.

And since you are using Hosted Build Agent, it would be a little troublesome to install git-lfs via Chocolatey on it as you don't have administrator permission. An alternative way would be download the binary files for git-lfs directly and upload it into Source Control. Then you can invoke the git-tfs.exe with an absolute path in your script.

Eddie Chen - MSFT
  • 29,708
  • 2
  • 46
  • 60
1

Here are some more details around the solution provided by Eddie. git lfs is not a built-in command. It is a git custom command.

When you call git lfs, git.exe does not know about the lfs command. So it looks in the PATH environment variable and searches for a program named git-lfs.exe. Once found, it calls that program with the provided argument.

So calling git-lfs.exe pull is equivalent to calling git.exe lfs pull.

The solution suggested is therefore to download git-lfs.exe, add it your git repo (it should obviously not be tracked by LFS), and call git-lfs.exe.

It is also possible to add the folder that contains git-lfs.exe to your path environment variable. This makes it possible to use commands like git.exe lfs pull as you usually do.

mabead
  • 2,171
  • 2
  • 27
  • 42
0

If you are allowed to install software and have internet access during build you might be able to install git-lfs using the Chocolatey package in a cmd / PowerShell task prior to your git-lfs operation.

Pascal Berger
  • 4,262
  • 2
  • 30
  • 54