Git: Revert to previous commit status

MrBubbles picture MrBubbles · Feb 15, 2011 · Viewed 23k times · Source

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

Answer

Marc W picture Marc W · Feb 15, 2011

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.