Last active
December 27, 2019 02:46
-
-
Save sfdcale/ef1c7c2d2e4c709d3db600f86b81524e to your computer and use it in GitHub Desktop.
Script to delete merged branches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| git remote prune origin | |
| rm -f branchesToDelete.txt | |
| git branch -r --merged TEST > branchesToDelete.txt | |
| sed -i '.bak' 's/^[ \t]*origin\///g' branchesToDelete.txt | |
| sed -i '.bak' '/master/d; /QA_branch/d; /Production/d; /OSA_Invoices_Payment/d; /TEST/d; /Invoice_One_Time_Payment/d;' ./branchesToDelete.txt | |
| input="branchesToDelete.txt" | |
| while IFS= read -r branchName | |
| do | |
| echo "$branchName" | |
| git push origin --delete $branchName | |
| done < "$input" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment