Skip to content

Instantly share code, notes, and snippets.

@scodx
Created October 5, 2017 02:38
Show Gist options
  • Save scodx/f0fc1f99867b11c0e422bccfbc9490b9 to your computer and use it in GitHub Desktop.
Save scodx/f0fc1f99867b11c0e422bccfbc9490b9 to your computer and use it in GitHub Desktop.

Undo a commit and redo

git reset HEAD~

This leaves your working tree (the state of your files on disk) unchanged but undoes the commit and leaves the changes you committed unstaged (so they'll appear as "Changes not staged for commit" in git status, and you'll need to add them again before committing). If you only want to add more changes to the previous commit, or change the commit message1, you could use git reset --soft HEAD~ instead, which is like git reset HEAD~ but leaves your existing changes staged.

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