Find unmerged Git branches?

Try this:

git branch --merged master

It does what it says on the tin (lists branches which have been merged into master). You can also pull up the inverse with:

git branch --no-merged master

If you don’t specify master, e.g…

git branch --merged

then it will show you branches which have been merged into the current HEAD (so if you’re on master, it’s equivalent to the first command; if you’re on foo, it’s equivalent to git branch --merged foo).

You can also compare upstream branches by specifying the -r flag and a ref to check against, which can be local or remote:

git branch -r --no-merged origin/master

Leave a Comment