Skip to content

Instantly share code, notes, and snippets.

@manuelmorales
Created February 5, 2012 18:29
Show Gist options
  • Save manuelmorales/1747053 to your computer and use it in GitHub Desktop.
Save manuelmorales/1747053 to your computer and use it in GitHub Desktop.
Remove commits from Git history
export BRANCH=edge
export FIRST="hash_of_the_commit_from_which_to_start_forgetting"
export SECOND="hash_of_the_commit_from_which_to_keep_commits"
git checkout $BRANCH
git checkout $SECOND
git reset --soft $FIRST
git commit -C $SECOND
git rebase --onto HEAD $SECOND $BRANCH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment