I am trying to inspect the history of a repository. I stopped at a point where I want to return the repository back to a specific commit. I searched and I did
git reset --hard 12345
I got the message that HEAD is now at 12345. I opened the folder to see the file I wanted to see but it didn't change!
I wanted to go back to 2009 when that file first created. However the file was in the new version (after editing it in 2010).
I checked the working directory but nothing there. I also ran
git clean -f -d
but nothing changed.
I don't know what should I do now. I want to go back in time to see how files were look like, but I want to go back to the whole repository.
To be fair, I do not understand what happened to your repo after you did
git reset --hard 12345
What should be stressed is that you should usually avoid "git reset --hard" command. The risk is to lose any uncommitted change that you had and also end up with dangling commits. You would really use that command if you want to throw away all the commits that have been made after commit 12345. I invite you to read this thread about git reset --hard
In your case, I would actually have created a temporary branch "temp_branch" that would point towards the commit 12345. The command would be
git checkout -b temp_branch 12345
This will switch the repo to new branch "temp_branch", whose HEAD will be 12345. The creation of a new branch is not compulsory but I find it convenient if I need to make a change from that commit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With