Git checkout not working

2.4k Views Asked by At

I committed my changes.

When I enter git log I can see that it's there.

commit 5d6eebd2f064fc2ba59fdc55cdebb728e607de0e
Author: Imray <[email protected]>
Date:   Thu Nov 13 22:16:30 2014 -0500

So now I make some silly gibberish changes in one of my files and save.

When I enter git checkout 5d6eebd2f064fc2ba59fdc55cdebb728e607de0e my files should revert back to what they were when I committed them, but they are not. The gibberish is still there.

Does anyone know why this is happening? Am I missing something?

2

There are 2 best solutions below

0
On BEST ANSWER

This is intended Git behavior. Try this

git checkout <hash> <your_file>

Explanation: Imagine you did some edits and now you realize you are on the wrong branch. Simply changing branches should not revert your changes then. You would have no way of getting them back.

0
On

The real problem is that I was in the wrong directory.

I had copied all my work to a folder in the WAMP directory and continued working from there.

I feel like an idiot.