Created
March 25, 2015 16:33
-
-
Save roshangautam/299519189954e6143cc2 to your computer and use it in GitHub Desktop.
git-truncate-commit-history.sh
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 | |
if [[ $# -ne 3 ]] | |
then | |
echo "Usage $0 <repository path> <commit hash> <branch name>" # missing parameters | |
exit 2 | |
fi | |
cd $1 | |
git checkout --orphan temp $2 | |
git commit -m "Initial Commit" | |
git rebase --onto temp $2 $3 | |
git branch -D temp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment