Given two (or more) commits, I want to find the oldest merge which joins them. Something like the opposite of git merge-base
(which finds the youngest common ancestors). Notice that the commit I’m looking for will be a younger descendant of the starting commits.
In other words: I want to investigate the merge commit which merged two given commits (where changes to the same file happened).
oldest-merge() {
( for c; do git log --all --merges --ancestry-path ^$c --pretty='%aI %h %s'; done ) \
| sort | uniq -c | awk "\$1 == $# {print;exit}"
}
oldest-merge `git rev-list --all --grep=BUG-27182` # e.g.
the final awk takes the first commit that showed up in all the merge-ancestry lists.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With