Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Reta110/0c7bda8d752dda4424f22e15f9556a2a to your computer and use it in GitHub Desktop.
Save Reta110/0c7bda8d752dda4424f22e15f9556a2a to your computer and use it in GitHub Desktop.
#Watch the remote braches to look the list that we are going to delete:
git branch -r | sed 's/origin\/\(.*\)/\1/g' | cut -c 3- | grep -E 'fix_*' //->fix_ is the word to filter
RESULT:
fix_01032022_2
fix_01042022
fix_01042022_1
fix_01042022_2
#Deleting all of them:
git push origin -d `git branch -r | sed 's/origin\/\(.*\)/\1/g' | cut -c 3- | grep -E 'fix_*'` //->fix_ is the word to filter
RESULT:
- [deleted] fix_01032022_2
- [deleted] fix_01042022
- [deleted] fix_01042022_1
- [deleted] fix_01042022_2
NOTE:
This code is for substr the string:
| sed 's/origin\/\(.*\)/\1/g' | cut -c 3- |
Resutl: "origin/name_of_the_branch" -> "name_of_the_branch"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment