Reputation: 21698
I know that I can rename a branch with
git branch -m new-branch-name
And also that I can rename that branch from another branch with:
git branch -m old-branch-name new-branch-name
but I want to know if i can rename a range of branches replacing a path from all of them. For example
foo/bar/1.2
foo/baracca/1.2
foo/baratro/1.2
foo/barbabietola/1.2
foo/bartender/1.2
Should be changed in "replace 1.2 in 1.3"
foo/bar/1.3
foo/baracca/1.3
foo/baratro/1.3
foo/barbabietola/1.3
foo/bartender/1.3
or "replace foo with me"
meh/bar/1.2
meh/baracca/1.2
meh/baratro/1.2
meh/barbabietola/1.2
meh/bartender/1.2
Upvotes: 0
Views: 214
Reputation: 30327
I would do it like this:
git branch | grep 1.2 | while read branch; do
new_branch=$( echo $branch | sed 's/1.2/1.3/' )
echo moving $branch to $new_branch
# enable next line when we are sure the name of the branches is correct
# git branch -m $branch $new_branch
done
Upvotes: 2