Git Reset Hard

July 9, 2017

Here is how you can backup one commit in Git. The situation is where you've just committed to a branch and want to backup and throw this recent commit away.

Get the SHA of the previous commit then git reset hard to it.

For example,

$ git reset --hard 2acdd9bcdbd71a4ee919c90c0e964778346c54d1

Tags: git