Created
September 14, 2013 12:52
-
-
Save c9s/6561791 to your computer and use it in GitHub Desktop.
Script to truncate git history.
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
#!/bin/bash | |
rev=$1 | |
if [[ -z $rev ]] ; then | |
echo "[rev] is required." | |
exit | |
fi | |
# create history branch from $rev | |
git branch history $rev | |
parent_rev=`git rev-parse $rev~1` | |
combined_rev=`echo '[Truncated history]' | git commit-tree "$parent_rev^{tree}"` | |
git rebase --onto $combined_rev $parent_rev | |
echo "Now you can push history branch to remote." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
Truncate history from rev
984503ec73
: