Guest User

Untitled

a guest
Jul 19th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. # Deletes local branches that have been deleted on the remote
  2.  
  3. # Make sure you're on master because it should never get pruned
  4. git checkout master &> /dev/null
  5.  
  6. # Prune branches
  7. git fetch origin --prune &> /dev/null
  8.  
  9. # List branches that have been removed from origin and write to file
  10. git branch -vv | awk '/: gone]/{print $1}' > /tmp/branchesToPurge
  11.  
  12. # Open the file for editing
  13. vim /tmp/branchesToPurge
  14.  
  15. # Print list of branches to be deleted
  16. echo "The following branches will be deleted:"
  17. cat /tmp/branchesToPurge
  18.  
  19. # Ask if we should proceed
  20. read -p "Are you sure you want to delete these branches (y/n)? " answer
  21. case ${answer:0:1} in
  22. y|Y )
  23. echo "Deleting...";
  24. # Delete branches listed in file
  25. xargs git branch -D < /tmp/branchesToPurge
  26. exit;;
  27. * )
  28. echo "Aborted";
  29. exit;;
  30. esac
Add Comment
Please, Sign In to add comment