In git help log
and git help revisions
, it is documented how to include or exclude specific commits/refs and their ancestors in git log
.
I am now looking for a way to exclude children of a given rev, and combine this with other range specifiers.
So:
- Include TARGET and its ancestors
- Exclude BASE_1 and all its parents / ancestors, even if they are ancestors of TARGET.
- Exclude BASE_2 and all its parents / ancestors, even if they are ancestors of TARGET.
- Exclude START_1 and all its children / descendants, even if they are ancestors of TARGET. In my case, START_1 is an ancestor of TARGET, but is not an ancestor of any of the other revs I am excluding.
The first three steps can be done with ^
negation, or with --not
.
git log TARGET ^BASE_1 ^BASE_2
The last step would require something new, which I don't know if it exists.
git log --exclude-descendants-of=START_1 TARGET ^BASE_1 ^BASE_2
Use case / motivation
We have an "acceptance" branch which merges a lot of feature branches. It also contains some commits that were done directly on acceptance, to amend faulty merges (don't judge!).
I am rebasing this on master with git rebase -i --rebase-merges
to preserve branch topology.
I want find out which feature branches were merged to the old version, but not (yet) to the rebased version. I want to exclude from this list the feature branches that I already know to be missing, so that I can narrow it down step by step.
So I would have something like this:
git log --exclude-descendants-of=START_OF_OLD_ACC origin/acceptance ^acceptance ^FEATURE_1 ^FEATURE_2
What I considered so far
I already found --ancestry-path
. But I don't see how I can negate this and combine with other range specifiers to achieve the desired result.
Alternatives
Alternatively, I would already be happy if I could exclude all commits that appear in git log --first-parent TARGET
, because these happen to be more or less the same as the descendants I would like to exclude.