Reputation: 126
What I want to achieve is a Git graph log where each branch has one single column allocated to it.
$ git log --graph --all --topo-order --decorate --oneline --boundary \
--force-branch-columns=master,dev
* f745bf5 (HEAD, newbranch) Merge branch 'master' into newbranch
/|
/ * 7031537 commit
/ * 416ab2c commit
| * | a9f8d93 (dev) Merge branch 'master' into dev
|/| |
* | | 5f32650 (master) commit
| * | b511501 Merge branch 'master' into dev
|/| |
* | | 4e6810e commit
| * | 2cd55b4 Merge branch 'master' into dev
|/|/
| /
|/|
* | 4f74695 commit
| * 372799e Merge branch 'master' into dev
|/|
* | 076669f commit
\|
* 7382440 initial empty commit
This is where I found some results but not a way to implement any: https://gist.github.com/michaelhood/5075495
$ git log --graph --all --topo-order --decorate --oneline --boundary \
--force-branch-columns=master,dev
Upvotes: 4
Views: 279
Reputation: 60635
You can get close with e.g.
git show-branch master dev newbranch
which allocates a column per branch.
Upvotes: 2
Reputation: 490178
There is not—but it's also worth noting that such a feature would be misleading.
The fact that commit 4e6810e
, for instance, is on branch master
does not change the fact that commit 4e6810e
is on branch newbranch
. Many commits are on many branches simultaneously. The set of branches that contain any one commit C changes over time as branch names are created and destroyed.
The graph remains constant throughout. It's just the labels—the branch names—that change.1 The statement commit C is on branch B simply means that by starting at the commit identified by name B, and working backwards through all paths through the history formed by the commit graph, Git can reach commit C.
Git does have the notion of working backwards through the graph but following only the first parent at each merge. That is, given a graph like:
...--o--o--o--o---o--o <-- name1
\ /
o--o--o--o <-- name2
one can have Git start at the tip commit identified by name1
and walk backwards through both rows of commits, or start at the tip commit identified by name1
and walk backwards only along the top row (assuming that the first parent of the merge is along the top row). To achieve this, git log
and git rev-list
—the two principle graph-walking commands—have the option --first-parent
.
1For instance, after deleting the name master
, commit 4e6810e
would no longer be on master
(which no longer exists).
Upvotes: 4