Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the full git log after rolling back to a previous version

Tags:

git

windows

I'm new to git, and probably not using correct terminology, so bear with me :)

Let's say I have a repository with 5 changes, e.g.

D:\test\gitrepo2>git log --oneline
3a5fd33 555
3cfbfae 444
e9a78c8 333
a618586 222
b80d5e1 111

I learned that I can sync back to an earlier revision by doing:

D:\test\gitrepo2>git reset e9a78c8 --hard
HEAD is now at e9a78c8 333

My question is: after doing this, how can I get the full log, so that I can go back to the most recent revision?

Running log no longer shows those revisions:

D:\test\gitrepo2>git log --oneline
e9a78c8 333
a618586 222
b80d5e1 111

I also tried add the --all switch, which didn't make a difference. In Mercurial, under the same scenario, running 'hg log' gives the complete log even after I update to an earlier revision.

like image 303
David Ebbo Avatar asked Apr 20 '11 22:04

David Ebbo


1 Answers

I assume by "sync back" you really mean you just want your working copy to look like a previous point in time. To do that, you want checkout, not reset:

> git checkout e9a78c8

At that point, your repository looks like this:

> git log master --oneline
3a5fd33 555   <--- master is still here
3cfbfae 444
e9a78c8 333   <--- HEAD (working copy) is here
a618586 222
b80d5e1 111

Now to get back to the latest commit on master, just git checkout master again.

By using reset, you got this instead:

> git log master --oneline
e9a78c8 333   <--- HEAD (working copy) and master are here
a618586 222
b80d5e1 111
like image 129
dahlbyk Avatar answered Oct 11 '22 18:10

dahlbyk