Skip to content

Instantly share code, notes, and snippets.

@jameswilson

jameswilson/git-mdiff

Last active Sep 22, 2017
Embed
What would you like to do?
Git list merged branches in one branch, but not on another
#!/bin/bash
# Git command to compare which branches are merged into one branch but not
# present in another. Useful for comparing which branches have been merged
# into a release branch that are already on the mainline branch.
#
# Usage:
#
# git mdiff origin/master origin/integration
#
# - Reveals a list of remote branches that are present on integration but
# not on master.
#
#
# See https://stackoverflow.com/questions/8071079 for a nice situational
# diagram to explain the typical use case.
#
# The following command does not work as a git alias because it depends on
# Process Substitution <(..) and does not work with /bin/sh which is what
# git uses to process aliases.
#
comm -12 <(sort <(git branch -r --no-merged $1 )) <(sort <(git branch -r --merged $2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment