Skip to content

Instantly share code, notes, and snippets.

@nmenag
Last active February 23, 2020 21:22
Show Gist options
  • Select an option

  • Save nmenag/545ffcae086d3b0b455293b95af6dff8 to your computer and use it in GitHub Desktop.

Select an option

Save nmenag/545ffcae086d3b0b455293b95af6dff8 to your computer and use it in GitHub Desktop.
Rollback to last git commit

Git commands

  • To UNDO local file changes but NOT REMOVE your last commit, then use

git reset --hard

  • To UNDO local file changes AND REMOVE your last commit, then use

git reset --hard HEAD^

or

git reset --hard HEAD~

  • To KEEP local file changes and REMOVE ONLY your last commit, then use

git reset --soft HEAD^

or

git reset --soft HEAD~

Use git status and git log frequently to observe your current state.

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