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.

  • Git rebase from multiple branches not getting changes
  • How to make an existing git branch track a remote SVN branch?
  • Jenkins and multiple git branches?
  • Git branches with completely different content
  • Does TFS branching have a child parent relation?
  • Publishing a gitflow feature branch to gerrit
  • 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

  • How to create a git clone with branches of a “subproject”?
  • Undo git merge but add commits made after a merge
  • Avoiding ASP.NET passwords in github?
  • Writing a git post-receive hook to deal with a specific branch
  • Git log decorated graph with appended information
  • Using GIT and a CDN for static content
  • 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.