Kamal rajput
Kamal rajput

Reputation: 11

How to rename branch names on svn when migrating to git

I have few multi module projects which i have to migrate to git and generate a parent aggregator project out of it. The projects on svn has different naming convention on svn , and i want to rename the branches to make it standard through out the code structure.

ex- project1
branches - project1_121
           213
           project1_454

project2
branches - project2_121
           project2_213
           project2_454

i want to rename these branches to have a number common across multiple projects. The branches should be renamed in a manner such that

project1_121 and project_121 will become 121.

Steps i performed :

git svn clone "svn url"
now i want to change the branch name:
so for that i need to checkout the branches and rename. As i have hundreds of branches in each proect. Is there any alternative to do it easily and in a less error prone way.

Upvotes: 0

Views: 278

Answers (1)

EncryptedWatermelon
EncryptedWatermelon

Reputation: 5598

Not sure if you can modify git svn clone to modify branch names but you could write a script to rename branches.

This will rename any branch in the format abc_123 to 123

for x in `git branch`; do 
  new_name=`echo $x |grep -E [0-9]*$`
  git branch -m $x $new_name
done

Upvotes: 1

Related Questions