Skip to content

Instantly share code, notes, and snippets.

@rollxx
Created February 22, 2012 10:31
Show Gist options
  • Save rollxx/1884075 to your computer and use it in GitHub Desktop.
Save rollxx/1884075 to your computer and use it in GitHub Desktop.
git remove a local commit

$ git rebase -i HEAD~5

  • Don't use git-rebase on public (remote) commits.
  • Make sure your working directory is clean (commit or stash your current changes).
  • Run the above command. It launches your $EDITOR.
  • Replace pick before C and D by squash. It will meld C and D into B. If you want to delete a commit then just delete its line.

If you are lost, type:

$ git rebase --abort

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment