Skip to content

Instantly share code, notes, and snippets.

@pcreux
Created July 4, 2012 08:25
Show Gist options
  • Save pcreux/3046084 to your computer and use it in GitHub Desktop.
Save pcreux/3046084 to your computer and use it in GitHub Desktop.
delete remote branches behind master
to_delete = []
branches = `git branch -r | grep origin`
branches.each_line do |branch|
branch.strip!
next if branch['master']
puts branch
puts cmd = "git diff --stat origin/master...#{branch}"
if `#{cmd}`.empty?
to_delete << branch
end
end
p to_delete
to_delete.each do |br|
br.gsub!("origin/", "")
puts cmd = "git push origin :#{br}"
system cmd
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment