Sirop4ik
Sirop4ik

Reputation: 5253

How to exclude files from repo that was added to lfs?

There is such story - I added some binary files to commit and pushed them to repo. Then I noticed this and add these files to .gitattributes in order to upload them in lfs.

As far as I understood after first time when I pushed my commit with binary files to repo without lsf , git starts to track these files and now I am not sure that it is enough just to add files to .gitattributes I assume I need somehow to say to git that I don't need to track these file in git, just in lfs... But I am not sure

So, question is - how to make sure that after I have added files (that were pushed) to .gitattributes they are actually in lfs and not in regular git repo

Upvotes: 1

Views: 778

Answers (1)

Marcin Pietraszek
Marcin Pietraszek

Reputation: 3214

A quote from Github's documentation:

Note that defining the file types Git LFS should track will not, by itself, convert any pre-existing files to Git LFS, such as files on other branches or in your prior commit history. To do that, use the git lfs migrate command, which has a range of options designed to suit various potential use cases.

To exclude already committed files you need to rewrite history. During that process you'll remove those large files from git repository and leave them in LFS. To do that you can use existing command:

git lfs migrate import

As mentioned above that will rewrite existing history, which is not always the best thing to do, especially when the history is already published.

Upvotes: 2

Related Questions