Last active
December 24, 2024 17:02
-
-
Save jkeefe/0d3c21f0cb0c9a432536be9c39e39008 to your computer and use it in GitHub Desktop.
Removing large files from Github repo commit history
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
# example: get rid of large `.tif` and `.nc` files in gis/tmp | |
# from https://www.geeksforgeeks.org/how-to-remove-a-large-file-from-commit-history-in-git/ | |
git filter-branch --force --index-filter \ | |
'git rm --cached --ignore-unmatch gis/tmp/*.tif' \ | |
--prune-empty --tag-name-filter cat -- --all | |
git filter-branch --force --index-filter \ | |
'git rm --cached --ignore-unmatch gis/tmp/*.nc' \ | |
--prune-empty --tag-name-filter cat -- --all | |
git push origin --force --all | |
# Caveat: Force pushing rewrites history on the remote server, which can disrupt other | |
# developers who have already pulled that branch. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment