Skip to content

Instantly share code, notes, and snippets.

@jcromartie
Created March 29, 2011 18:47
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jcromartie/892979 to your computer and use it in GitHub Desktop.
Save jcromartie/892979 to your computer and use it in GitHub Desktop.
Git command to list merged (or unmerged with -u) branches
#!/bin/ruby
show_unmerged = ARGV[0] == '-u'
branches = `git branch -r`.split("\n")
branches.each do |branch|
is_merged = `git branch --contains #{branch}` =~ /master/
puts branch if show_unmerged ^ is_merged
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment