Search code examples
gitcommitreset

Git: Revert to previous commit status


I'm confused. I want to go back to a previous commit that I identified in "git log".

But when I do "git checkout ", I don't get said commit. Nothing changes. It tells me I'm in detached HEAD mode, but the files I want are not there.

What the eff am I doing wrong?

MrB


Solution

  • git reset --hard <commit> From the manpage:

    Matches the working tree and index to that of the tree being switched to. Any changes to tracked files in the working tree since are lost.

    git checkout is for switching your working directory to a different branch or commit. This does not move the HEAD there.