Skip to content

Instantly share code, notes, and snippets.

@roshangautam
Created March 25, 2015 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roshangautam/299519189954e6143cc2 to your computer and use it in GitHub Desktop.
Save roshangautam/299519189954e6143cc2 to your computer and use it in GitHub Desktop.
git-truncate-commit-history.sh
#!/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