Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. function gitLocalCleanup() {
  2.  
  3. # loop through results of git branch
  4. # cut removes the * from checked out branch
  5. # grep regex allows for alphanumeric with dash and/or underscore
  6.  
  7. for x in `git branch | cut -c 3- | grep -e "[\-\_0-9A-Za-z]*"`;
  8. do
  9. echo "Delete $x? (y/n)";
  10. read confirm;
  11.  
  12. if [[ "$confirm" == "y" ]];
  13. then
  14. git branch -d $x; # use -D if you want force delete
  15. fi;
  16. git gc --auto;
  17.  
  18. done;
  19.  
  20. }
  21.  
  22. export -f gitLocalCleanup;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement