Revert Git to a previous commit


Working on your own and just want it to work?

To revert to a previous commit, ignoring any changes:

git reset --hard HEAD

To revert to a commit that's older than the most recent commit:

# Resets index to former commit; replace '56e05fced' with your commit code
git reset 56e05fced 

# Moves pointer back to previous HEAD
git reset --soft HEAD@{1}

git commit -m "Revert to 56e05fced"

# Updates working copy to reflect the new commit
git reset --hard

  • 0 posts
  • 0 subtopics
  • 9 months ago by vince