How to solve the problem if you set Git LFS but get an error when pushing

TiShow
Dec 12, 2021
https://unsplash.com/photos/wX2L8L-fGeA

There are many patterns that will cause an error if I push it, even though you set tracking (added to .gitattribute).

This causes because past files that have already been committed are not treated as LFS.

So we need to modify the past.

Use the git lfs migrate command for this.

git lfs migrate

You can check the files that have failed to convert to LFS with git lfs migrate info.

git lfs migrate import will rewrite past commits as LFS.

git lfs migrate import

You should be able to push now!

If you haven’t tracked it yet (not added to .gitattribute)
You can do it at the same time by specifying — include like git lfs migrate import — include = “[file pattern]”.

Happy coding !

--

--

TiShow

80% is the creation, the rest is depression. Developer and Data scientist. Looking for Physics Ph.D Twitter: @_t_i_show