What I wish to do is to get the version of the file that has a specific comment, get it and use it, then change it to the latest code.
git log -g --grep="code submitted version 0.1.2.3"
This returns a hash 123456
, then I do:
git checkout 123456
and use the older version.
Now I want to change the HEAD
back to the latest. This I could not do.
I have tried:
git reset --hard
git clean -f
git pull
Any ideas?
When you called git checkout 123456
you moved your HEAD
from the commit you were currently on (most likely the head of the master
branch) to the commit 123456
. Therefor you are looking for a way to move HEAD
back to the branch you were previously on, which you can do with:
git checkout master
If you want to take a look at a specific revision of a file, you can either just view it using
git show 123456:/txt/file.txt
or temporarily check out only this file with
git checkout 123456:/txt/file.txt
// use it
git checkout :/txt/file.txt
Explanation of your tries:
git reset --hard
Reverts all changes of the current HEAD
, but does not move HEAD
. After a reset, git status
shows that everything is "clean".
git clean
Removes all untracked files from the working tree, again HEAD
is not moved.
git pull
Fetches the upstream changes and merges them in. Not what you want.
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