Reputation: 1504
I am trying to convert an svn repository to git and I have mostly accomplished what I needed by doing the following:
git svn init https://svn.server.com/repos/my_repo --stdlayout
git svn fetch
I also found a way to convert all SVN branches to local Git branches:
for branch in `git branch -r | grep -v tags`; do
git branch $branch $branch
done
However, now I am stuck with a list of branches that look like this:
origin/1.3
origin/1.4
origin/1.5
origin/1.6
origin/1.7
origin/1.8
origin/2.0
What I'd really like to end up with is branch names that look like this:
1.3
1.4
1.5
1.6
1.7
1.8
2.0
I've tried looking into git filter-branch, but I'm not sure if that is exactly what I want. I also tried to specify my layout more manually like this:
git svn clone --trunk=/trunk --branches=/branches --tags=/tags https://svn.server.com/repos/my_repo
but this did not work either. It gave me the same results with origin/
before every branch name. I just wanted to know if it's possible to make these branch name changes without having to re-clone the entire repo again.
Here is the output of running git branch -a
:
git branch -a
* master
origin/1.3
origin/1.4
origin/1.5
origin/1.6
origin/1.7
origin/1.8
origin/2.0
Upvotes: 2
Views: 1753
Reputation: 802
It is possible to add
git branch -m old_name new_name
to the loop so that the part of the bash script becomes
for branch in `git branch -r | grep -v tags`; do
new_branch=$(echo $branch | sed 's/origin\///')
git branch $branch $branch
git branch -m $branch $new_branch
done
It can be made prettier but it gets the job done and shows that you can rename branches.
Upvotes: 3