Created
February 18, 2015 16:33
-
-
Save s4parke/79f09b52ff92e5f33989 to your computer and use it in GitHub Desktop.
Simple bash script for truncating git repo 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
#!/bin/bash | |
# Usage: | |
# ./git-truncate.sh SHA1 | |
# Removes all the history prior to commit "SHA1" | |
git checkout --orphan temp $1 | |
git commit -m "Truncated history of git repo" | |
git rebase --onto temp $1 master | |
git branch -D temp | |
# Optional, may take awhile | |
git prune --progress | |
git gc --aggressive |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment