I think that this can be done by using a combination of git branch --contains <id>
(as suggested by torek in a comment on the question) and git rev-list
.
Specifically, assuming that you have local branches for all of the branches you're interested in (if not, try adding -r
or -a
to the git branches
command), then the following should do what I think you're after:
$ git rev-list $(git branches --contains <ancestor>) --not <ancestor> --pretty=oneline
git
rev-list
is a command which will give a list of all revisions which are reachable from some parents but not others.
In the above invocation, we're using the list of all branches which contain the given ancestor as the starting points and then excluding all the history prior to that ancestor.
Adding --pretty=oneline
tells the command to include a brief description of the commit; it would normally just output the revision ids one-per-line.
Bear in mind that this may not quite do what you're after as I think the commits are ordered chronologically rather than by the topological graph of commits.
git rev-list
has a large number of options though, so there's probably one which can control that ordering.
If you really do want to just list all the commits which have a given ancestor, then there's a more brute-force way to do that (though it will include otherwise unreachable commits and stashes).
Again we use rev-list
, though instead of passing the list of interesting branches, we just specify --all
:
$ git rev-list --all --not <ancestor> --pretty=oneline
^ `.
– torek Nov 03 '15 at 22:08