In the case of your example you'll want to use git branch -a --merged integrationBranch
The two branches origin/branch1
and origin/branch2
are remote branches and aren't listed with git branch
by default so neither is showing up in your output unless you use a -a
switch.
I'm guessing the reason you are seeing branch2
is that you probably have a local branch named branch2
which is merged in (ie, the problem is not that the command is dropping the first branch)
EDIT:
To get all of the branches merged into integrationBranch
but not into master
you could do:
git branch --list -a --merged integrationBranch | sed 's/^..//;s/ .*//' | xargs git branch --list -a --no-merged master