How to pull LFS files (GitLab)

I am primarily using GitLab and just started using LFS. When I commit+push LFS tracked files teammates who pull the commits down only get stubs for the files. Any ideas on what we are missing?

1 answer

0 votes

Hi Sean,

When your colleagues clone a repository with LFS content, two things are necessary to ensure the LFS pointers are replaced with the real objects.

Firstly, they must have LFS installed on their Git client. For the command line client this means running the "git-lfs install" command, which will add the following lines to the .gitconfig file in their home directory:

[filter "lfs"]
clean = git-lfs clean %f
smudge = git-lfs smudge %f
required = true

Next, the committer (you in this case) must have ensured that the .gitattributes file was checked in. This file is updated when you run the "git lfs track" (or untrack) commands. It will have lines like this:

*.jpg filter=lfs diff=lfs merge=lfs -text
*.tif filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text

So, with those two things, when your colleagues clone or pull from the repository two things happen. Their Git client knows to run the "git-lfs" filter, and then the filter knows that for each of the file patterns in the .gitattributes file that it should fetch (if necessary) the real objects from LFS.

Hope this helps.



Thanks. It must be the git lfs install that is missing. 

I think I was under the impression that .gitconfig gets committed, but I'm seeing it does not.

I was also under the impression that SourceTree had git-lfs installed and didn't need the git lfs install command.

So does that need to be done for every repository or is it global?

Also, it would be awesome if the lfs filter in the gitattributes triggered some sort of warning to tell the user to run git lfs install. Odd thing is: I thought it did give an error about clean and smudge, but my colleague's client never complained.

Thanks again. I'll share this with him and hopefully it will rectify future issues.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Thursday in Agile

Managing Projects in Several Jiras at the Same Time

Have you ever noticed that fixing specific problems might be a door opener for a bigger challenge, affecting a wider audience? This was exactly the case when we, as a service company working with mul...

181 views 3 13
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you