tags:

views:

186

answers:

3

I have a git repository with multiple branches.

How can I know which branches are already merged into the master branch?

+3  A: 

You can use the git merge-base command to find the latest common commit between the two branches. If that commit is the same as your branch head, then the branch has been completely merged.

Note that git branch -d does this sort of thing already because it will refuse to delete a branch that hasn't already been completely merged.

Greg Hewgill
+7  A: 

If found myself the answer:

git branch --merged lists the branches that are already merged

git branch --no-merged lists the branches that have not been merged

hectorsq
+1  A: 

@hectorsq: here’s a community owned copy of your answer if you want to mark it as answered.

  1. git branch --merged lists the branches that are already merged
  2. git branch --no-merged lists the branches that have not been merged
Pat Notz