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.

  • How to get only changes from branch's branch in git?
  • how to create git branch in remote repository without checking out using jgit
  • Are there different meanings to the concept of 'tracking' in git?
  • Branching in Mercurial
  • Update a local branch with the changes from a tracked remote branch
  • Syncing two GIT branches that only differ by a couple of files
  • EDIT:

    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

  • git rebase a branch since it was created
  • How do I do automatic tracking of filename changes with GIT?
  • What does the “at” @ sign/symbol/character mean in Git?
  • Precompiling assets failed ExecJS::ProgramError: Unexpected token: operator (=) (line: 10770 , col: 0, pos: 300859)
  • trustExitCode = false not working with Araxis merge for mac and Git
  • A single command to git pull a branch?
  • 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/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)


    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
    Git Baby is a git and github fan, let's start git clone.