Last active
July 25, 2022 21:45
-
-
Save benoit-dubreuil/4a262597e0d8a82d29b74e4507c470f3 to your computer and use it in GitHub Desktop.
Remove Git LFS from repo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# See https://stackoverflow.com/a/35064134/2924010 | |
# TODO : Rewrite history | |
# You must `cd` in your local repository beforehand. | |
LFS_FILES_EXTENSIONS="""*.7z | |
*.br | |
*.gz | |
*.tar | |
*.zip | |
*.gif | |
*.ico | |
*.jpg | |
*.png | |
*.tif | |
*.tiff | |
*.psd | |
*.webp | |
*.woff2 | |
*.exe""" | |
while IFS="" read -r extension || [ -n "$extension" ]; do | |
git lfs untrack "*$extension" | |
done <<<"$LFS_FILES_EXTENSIONS" | |
git lfs uninstall | |
# WARNING! Disable this if you have custom hooks unrelated to Git LFS! | |
rm .git/hooks/pre-push | |
# WARNING! Disable this if you have custom behaviours unrelated to Git LFS in the file '.gitattributes'! | |
rm .gitattributes | |
while IFS="" read -r extension || [ -n "$extension" ]; do | |
git rm --cache "*$extension" | |
git add --force "*$extension" | |
done <<<"$LFS_FILES_EXTENSIONS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment