Reputation: 28734
I revert my code to previous version, now I want to revert it back to my latest version. How can I do that ? Thanks
Upvotes: 0
Views: 709
Reputation: 60235
You can walk back through the history of individual refs (tags, branches, checkouts) with e.g. HEAD@{1}
, the last place you checked out before this one, and you can get a nice historical table of contents with git log -g --decorate --oneline
.
William Pursell pointed out git reflog
, a much simpler command than git log, focused only on the work-history logs in .git/logs
.
Upvotes: 1
Reputation: 3934
What do you mean by 'revert' ? git revert ?
You can use git reset --soft YOUR_SHA
to point HEAD to a specific commit. Or a simple git checkout master
to return back to the 'trunk' if you are lost in a "detached head" status...
The answer depends really on what your current status is.
Upvotes: 1
Reputation: 1876
if you used
git checkout <commit hash>
then your code is in a detached state, meaning it belongs to no branch. you can simply do a git checkout branch_name
to bring code to the latest revision
if you used
git reset <commit hash>
then you can clean up your changes and then
git pull
or if you remember the <commit hash>
of your latest revision,
git reset <commit hash>
Upvotes: 0
Reputation: 13467
Try the following:
git checkout master
(or what did You mean by revert?)
Upvotes: 1