Guest User

Untitled

a guest
Oct 18th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. Description
  2. ======================
  3.  
  4. Find and delete old git branches that are no longer needed.
  5.  
  6. Usage
  7. ======================
  8.  
  9. Clone the repo and add to your path (just for ease of use):
  10.  
  11. git clone git://gist.github.com/2891516.git gist-2891516
  12. cd gist-2891516
  13. export PATH="$PATH:$(pwd)"
  14.  
  15. Now go to your project.
  16.  
  17. # list branches that have been merged to the current branch
  18. git old-branches
  19.  
  20. # list branches that have been merged to the remote:
  21. git old-branches github/master
  22.  
  23. # format branch delete commands according to user:
  24. git old-branches github/master | format_branch_deletes
  25.  
  26. Example output:
  27.  
  28. $ git old-branches | format_branch_deletes
  29. # schiang@comverge.com
  30.  
  31. git branch -d remove_new_relic # 301a52b (5 hours ago) <schiang@comverge.com>
  32. git branch -d something # 301a52b (5 hours ago) <schiang@comverge.com>
  33.  
  34. $ git old-branches github/master | format_branch_deletes
  35. # schiang@comverge.com
  36.  
  37. git push github :30434977_fix_the_clock # a262408 (3 weeks ago) <schiang@comverge.com>
  38. git push github :add_non_existant_methods # f47c5c9 (10 days ago) <schiang@comverge.com>
  39. git push github :manual_requires # c9bcc3f (3 weeks ago) <schiang@comverge.com>
  40. git push github :unnecessary_fsr # 54f4eb4 (9 days ago) <schiang@comverge.com>
  41.  
  42. The idea is that you can check the delete commands and execute as needed. Note
  43. that once the remote branches are deleted your teammates may have to prune the
  44. deleted branches from their local copies:
  45.  
  46. # use --dry-run option first as a precaution
  47. git remote prune github
Add Comment
Please, Sign In to add comment