Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git branch --merged using plumbing commands

Tags:

git

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)?

like image 1000
EnToutCas Avatar asked Feb 27 '13 16:02

EnToutCas


1 Answers

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.

like image 193
Dan Fabulich Avatar answered Oct 04 '22 18:10

Dan Fabulich