Is there a way to achieve the equivalent of
git branch --merged
using git plumbing commands?
I know there are commands like git for-each-ref which gives you the commit hashes and their corresponding ref names. Is there a command to tell whether a commit is reachable from another commit (which is basically what --merged do)?
git merge-base --independent X Y Z will tell you which of those are not yet merged to another branch.
In addition, git merge-base --is-ancestor X Y will tell you whether X is an ancestor of Y, but that's an inefficient way to implement git branch --merged because you'll need to run it N^2 times for N branches.
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