Last active
September 14, 2020 09:12
-
-
Save schneefisch/c88103aeb1110114ebf985cac8983b38 to your computer and use it in GitHub Desktop.
remove the history of a git-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
# Case: | |
# The git-repo is enourmous an we want to drop a part of the history | |
# or, if we split a monolithic application, and the "new" application emerging from it should only have a few commits and not the whole history. | |
# | |
git checkout --orphan temp $1 # create a new branch without parent history | |
git commit -m "Truncated history" # create a first commit on this branch | |
git rebase --onto temp $1 master # now rebase the part of master branch that we want to keep onto this branch | |
git branch -D temp # delete the temp branch | |
# The following 2 commands are optional - they keep your git repo in good shape. | |
git prune --progress # delete all the objects w/o references | |
git gc --aggressive # aggressively collect garbage; may take a lot of time on large repos | |
#### | |
# then upload / push the files to a "new" repository |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment