Git – getting a list of branches that were merged into another branch
I’m having some trouble doing this in a non convoluted way… currently I can figure out which branches were merged into a branch by outputting branches –merged from the target branch and from master, writing the output from those commands to files, and then diffing those two files. Does anyone have a better way to get this info?
For example, say branches branch1, branch2, and branch3 are all cut from master and dev work is done on them. Then, branch1 and branch2 are merged into integrationBranch. The command should be able to tell me that branch1 and branch2 were merged into integrationBranch.
When I run git branch –merged, the branch that’s merged in first is always dropped from the output.
git checkout inegraionBranch git merge origin/branch1 git merge origin/branch2 git branch merged *integrationBranch branch2
One Solution collect form web for “Git – getting a list of branches that were merged into another branch”
In the case of your example you’ll want to use
git branch -a --merged integrationBranch
The two branches
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
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)
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