Razor
Razor

Reputation: 17508

Log entries are missing after checking out a previous commit

After rolling back to a previous commit in git using:

git checkout <commit hash>

and then perform a git log, all my log entries after the commit I just checked out are missing.

How do I get a listing of all commits once I've checked out a previous commit? I need to checkout the latest and go forward in time.

Upvotes: 6

Views: 2289

Answers (3)

Andrew Marshall
Andrew Marshall

Reputation: 97004

git log shows the log from the current HEAD. Assuming the branch you want to see the log of is "master", to see the "full" log again you can do either of the following:

Checkout the branch and then run git log:

git checkout master
git log

Pass a reference to git log to use as the HEAD:

git log master

and then have a reference of "future" commits to checkout instead.

If you want to see a log of the changes to Git references (e.g. branches and HEAD), use git reflog.

Upvotes: 10

Chinmoy
Chinmoy

Reputation: 1476

please see git reflog show message.It helped me recover old local changes.

Upvotes: 1

manojlds
manojlds

Reputation: 301347

git checkout <commit hash> is not rolling back.

You might want to try git reset --hard <commit hash> if you want to "roll back" commits.

If you want log of the master branch ( if master is the branch that you were in), you have to do:

git log master

Currently, you checked out a particular commit and log will show commits till that commit only and not commits after that.

Also, if you had done this checkout to make commits over this commit, stop! You are in a detached HEAD state and it is mean't only for commit inspection. You can go back to master using git checkout master or you can even do git checkout -

Upvotes: 1

Related Questions