Reputation: 1026
git log
accepts multiple branch names as parameters, and using --graph
you get a nice tree-view of it. With --all
I see the complete tree, with --branches
I can even filter branch names.
I want to show the complete history of all (sub)branches of a specific branch. To that end, I want to know how can I git log
all branches that contain some commit?
With git branch --contains
, I can find all branches that contain a specific commit. So with some bash-wizardry, I could probably make up a command that does what I want. But I'm guessing that git should have a more direct way to get such a log.
Upvotes: 3
Views: 157
Reputation: 3841
git-for-each-ref(1) is the plumbing [1] power tool for finding refs (like branches) which have some property, like which ones contain a branch or a commit.
git for-each-ref --contains=name --format='%(refname)' refs/heads/
That gives us the branches. Now we can feed it to git-log(1):
git for-each-ref --contains=name --format='%(refname)' refs/heads/ \
| git log --stdin
That will of course give a lot of commits. We can confirm that we are
only traversing those branches by checking with --no-walk
since that
turns off revision walking (finding all reachable commits):
... | git log --no-walk --stdin
--stdin
git log $(command)
but with --stdin
we avoid
potential too-many-arguments errors--no-walk
if you want to
list only the given commits (this is just an example)Modern Git plumbing tools sometimes provide us with simple enough output to construct simple pipelines (i.e. no coreutils intermediary steps) to achieve our task in a few straighforward steps.
Upvotes: 0