Reputation: 9572
Is there any way to show a git log graph with reflog references like mybranch@{N}
? This would be useful after doing a rebase to see the previous and current versions of the branch in a graph. Basically what I want (I think) is git log --graph --walk-reflogs mybranch
but that gives me an error fatal: cannot combine --walk-reflogs with history-limiting options
.
I can get very close with git log --graph --reflog mybranch
but that does not show reflog references like mybranch@{1}
.
Maybe this is a limitation since you can't walk the ancestry and the reflog in the same command? Still, it seems like there should be a way to walk the reflog 5 entries or so and feed those references with labels to git log --graph
.
Upvotes: 6
Views: 2081
Reputation: 487963
Maybe this is a limitation since you can't walk the ancestry and the reflog in the same command?
That's exactly right.
The main issue here is that Git can only add these label-decorators (%d
for normal decorations, or %gD
for reflog selector decorations) to commits if it can find the decorator. To allow the %d
decorators to work, Git always reads all branch and tag and other reference names. But for %gD
to work, Git must read the reflog entries, and unless you use --walk-reflogs
(or -g
for short), it doesn't read the reflog entries at all. Once you do use -g
, it does read the reflogs, but stops walking the commit graph.
There's no fundamental reason Git couldn't read all reflogs if and when %gD
appeared in the formatting directives, so that it could add those decorators, but it doesn't today.
There's a separate, but equally important, problem that occurs if and when you solve this first one: --graph
cannot be combined with --no-walk
and --walk-reflogs
implies --no-walk
(they're separate internal walk functions and the graph-generating code depends heavily on using the history walker, not the reflog walker).
(The best you can do with current Git is parse the output from git log
, while also reading all the reflog values yourself. You can then write your own code to add reflog labels.)
Upvotes: 8