Skip to content

Instantly share code, notes, and snippets.

@davidthewatson
Forked from jcromartie/git-merged.rb
Created March 19, 2012 23:17
Show Gist options
  • Save davidthewatson/2128346 to your computer and use it in GitHub Desktop.
Save davidthewatson/2128346 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