6

From my understanding .gitattributes works similar as .gitignore. If I define a filter in .gitattributes, this filter will take effect and the files will be transferred to LFS.

In every GIT LFS related document (official documentation, stackoverflow answers, ...) it is recommended to run git lfs track.

Does git lfs track do anything else than writing the filter to .gitattributes?

1 Answer 1

13

git lfs track does two things: modify .gitattributes and adjust timestamps so that Git picks up any existing files and converts them to LFS objects. In addition, it does some sanity-checking to avoid duplicates and common mistakes.

There's no reason you can't just modify .gitattributes yourself, but note that if you do that, you should also run git add --renormalize . to make sure that any existing files matching the relevant patterns are converted to LFS.

Sign up to request clarification or add additional context in comments.

2 Comments

So basically if I add a new file to git that is not yet tracked it is save to only edit .gitattributes but if I want to convert an existing file to LFS I should use git lfs track.
You can use either technique for either case, but if your .gitattributes pattern matches existing files you need to run git add --renormalize . if you don't use git lfs track. Your approach does work, though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.