Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Revert to previous commit status

Tags:

git

commit

reset

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

like image 590
MrBubbles Avatar asked Feb 15 '11 13:02

MrBubbles


People also ask

How do I revert to a previous status in git?

git reset --hard This command reverts the repo to the state of the HEAD revision, which is the last committed version. Git discards all the changes you made since that point. Use the checkout command with two dashes, then the path to the file for which you want to revert to its previous state.


1 Answers

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.

like image 160
Marc W Avatar answered Nov 07 '22 20:11

Marc W