3

If I reset to a changeset that is, let's say HEAD^, then git log --all no longer displays the newer changeset above the current one. Is there a way to make it display as well?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Tower
  • 98,741
  • 129
  • 357
  • 507

1 Answers1

2

git reflog should display the commit previously referenced by HEAD before your reset.
(git reflog, your safety net)

See "Undoing a git reset --hard HEAD~1" as a concrete example.
You can also try, with git log alone, the -g option:

-g, --walk-reflogs

Instead of walking the commit ancestry chain, walk reflog entries from the most recent one to older ones

After all, git reflog can be done by a git log -g --oneline.

git log --walk-reflogs master # show reflog entries for master

The OP rFactor adds:

Can I filter out everything except Merge and Commit reflogs?
For example, I want to get rid of Checkout and Updating HEAD.

I don't see how you can achieve that without filtering the output.
Jefromi concurs in the comments:

git reflog ... | grep -v 'checkout:\|updating HEAD'

Also after you figure out what commit you want to see, you can then use log normally:

git log HEAD@{7} 
# or 
git log <SHA1>
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Is there a way I can force `git log` to display it? – Tower Nov 27 '11 at 16:31
  • Interesting. One more thing, can I filter out everything except Merge and Commit reflogs? For example, I want to get rid of Checkout and Updating HEAD. – Tower Nov 27 '11 at 16:49
  • @rFactor: `git reflog ... | grep -v 'checkout:\|updating HEAD'` – Cascabel Nov 27 '11 at 18:33
  • @rFactor: Also after you figure out what commit you want to see, you can then use log normally: `git log HEAD@{7}` or `git log ` – Cascabel Nov 27 '11 at 18:36