Skip to content

Instantly share code, notes, and snippets.

@tianhuil
Last active December 3, 2017 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tianhuil/a6675835a7a0c157fbcb296a743f52d4 to your computer and use it in GitHub Desktop.
Save tianhuil/a6675835a7a0c157fbcb296a743f52d4 to your computer and use it in GitHub Desktop.
Finds branches that can be safely merged
#!ipython
# to use this run these two steps
# curl https://gist.githubusercontent.com/tianhuil/a6675835a7a0c157fbcb296a743f52d4/raw/704a20201dd4362928f6e39ab0ab0bc0784b2af9/update_branches.ipy
# ipython merged_branches.ipy
!git checkout master
branches = !git branch
other_branches = [b.lstrip() for b in branches if b != '* master']
results = {}
for branch in other_branches:
!git checkout {branch}
r = !git rebase master
r_str = ''.join(r)
if 'CONFLICT' in r_str:
!git rebase --abort
else:
d = !git diff {branch} master
if len(d) == 0:
!echo "Can delete {branch}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment