Reputation: 451
We have an convention to add a prefix before branch name. Of course not every one followed that convention and now we have multiple branches that do not have a prefix.
So the task is to write a command(s) that:
1) get all branches that do not have one of the feature/bugfix/hotfix prefix
2) rename all those branches and add them a (lets say "misc") prefix
3) do not touch master branch
I did found something like this:
git branch | grep defects | awk '{original=$1; sub("defects","old-defects"); print original, $1}' | xargs -n 2 git branch -m
but I do not know who to reuse it in my situation
regards
mW
Upvotes: 1
Views: 556
Reputation: 25211
git branch --list \
| tr -d ' *' \
| egrep -v '^master$' \
| egrep -v '^(feature|bugfix|hotfix)_' \
| xargs -n 1 -I % echo git branch -m % misc_%
Remove the echo
if you want to really run the git
command.
Upvotes: 3