Reset

All types of reset will move the HEAD pointer to the commit specified.

-o-o-o-o-o-o-o   Original: HEAD pointing to the last commit
             |

-o-o-o-o-o o-o   Reset: HEAD replaced at an earlier commit
         |

The difference is what happens to the working tree and the staging index.

  • --soft: no rollback on either.

  • --mixed: keep the working tree, roll back the staging index; default option;

  • --hard: roll back both, like subsequent commits never happen. It's like git checkout with an attached HEAD.

Right after the hard reset, if you have the SHA you can still get to later commits. But if you do further development, subsequent commits might be lost.

Last updated