Last active
October 11, 2019 05:15
-
-
Save rpavlik/6346fc02ff86649a2933 to your computer and use it in GitHub Desktop.
Extreme git filter-branch: keep only one or a few files
This file contains 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
# Based on <http://git.661346.n2.nabble.com/Remove-all-files-except-a-few-files-using-filter-branch-td7567155.html> | |
# for most of it (the index filter part) and on this SO answer for how to get rid of the many meaningless commits now: | |
# <http://stackoverflow.com/a/5326065/265522> | |
git filter-branch --index-filter "git rm --cached -qr -- . && git reset -q $GIT_COMMIT -- THEFILEYOUWANTTOKEEP" # --prune-empty | |
git filter-branch --commit-filter 'git_commit_non_empty_tree "$@"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I find this script only keep files but not the history.