dev: Getting rid of Git LFS

This thing is a bit of a pain, it is very expensive on Github although they’ve lowered the price artificially, it is $5 for 50GB of Git LFS storage. As long as you keep your files less than 100MB you shouldn’t have a problem, but how do you get rid of it once you have it. That’s actually very hard

Removing Git LFS

There is a very specific sequence you need to run. Thanks to Ryan I think I have it:

# see how many files you have in your repo
git lfs ls-files
# get the real copies not the pointers
git lfs fetch --all
git lfs checkout
# now you can
git lfs uninstall
# now look at .gitattributes and for each line do
git lfs untrack "*.png"
# if you want to be fancy use xargs to do thie
cut -f 1 < .gitattributes | xargs "git lfs untrack {}"
# do this for all the lines in .gitattribute
rm .gitattributes
touch .gitattributes
# here is the key
git add -renormalize
# now push
git commit
git push

There you go, this will save you lots of hassle

Leave a Reply

Only people in my network can comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

I’m Rich & Co.

Welcome to Tongfamily, our cozy corner of the internet dedicated to all things technology and interesting. Here, we invite you to join us on a journey of tips, tricks, and traps. Let’s get geeky!

Let’s connect

Recent posts

Loading Mastodon feed…