Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Cloning SVN to BitBucket, branches are not created in git

kgleason January 6, 2014

I've been following the [steps from Atlassian](https://www.atlassian.com/git/migration#!migration-convert) for converting my SVN repositories to Git and then pushing them to BitBucket. Overall the process has been realtively painless. I've already moved loads of SVN to BitBucket, but up to this point the migration has dealt with realtively small and little used projects.

Now I'm trying to convert a more heavily used project, with lots of tags and some active svn branches. None of these repositories use a --stdlayout, so I am defining my layout manuallly. I've tried a few different things, and no matter what I do, `git branch` only every shows me the master branch. None of the other branches are being created.

Most recently, I tried this:

git svn clone --trunk="/MyProject/trunk/MyProjectMobileApp" --branches="/MyProject/branches/ProblemChild --branches="/MyProject/branches/ios7Work" --tags="/MyProject/tags/MobileApp" --tags="/MyProject/tags/released/MobileApp" --authors-file=authors.txt https://user@svn.fq.dn/svn/iOS MyProject

When that finished (almost 24 hours later), I ran

java -Dfile.encoding=utf-8 -jar ~/svn-migration-scripts.jar clean-git

The output indicated that it was going to delete branches from git that did not exist in Subversion:

# Checking for obsolete branches...
svn: warning: W160013: URL 'https://user@svn.fq.dn/svn/iOS/MyProject/branches/ios7Work' non-existent in revision 4448
svn: E200009: Could not list all targets because some targets don't exist
Deleting Git branch 'ios7work' not in Subversion.
Deleted branch ios7work (was f4ee5b6).
Deleting Git branch 'origin/master' not in Subversion.
Deleted branch origin/master (was 241bd27).
Deleting Git branch 'problemchild' not in Subversion.
Deleted branch problemchild (was 0a781d8).

Frustrating. The Problem child branch has been reintegrated back into trunk (in SVN), but it has not been deleted. So it does technically exist in SVN HEAD, but it is effectively dead. We have left it in place because we wanted to review a couple of things in it. The bigger problem in the ios7Work branch. It is alive. It has not been reintegrated, and also exists in SVN HEAD. The thing that is throwing me off is the warning on line 2 of the output above. My HEAD right now is r4447.

I found some documentation that indicated that something may be amiss with my config. So I ran the following:

git config --add svn-remote.ios7work.url https://user@svn.fq.dn/svn/iOS/MyProject/branches/ios7Work
git config --add svn-remote.ios7work.fetch :refs/remotes/ios7work
git svn fetch ios7work

It complained, so I google around a bit, and edited the .git/config to make the ios7work stuff look like this:

[svn-remote "ios7work"]
    url = https://user@svn.fq.dn/svn/iOS
    path = /MyProject/branches/ios7Work
    fetch = :refs/remotes/ios7work

This time the `git svn fetch ios7work` apeared to fetch a bunch of stuff, but when I ran the `clean-git` command from above I got the same output. I have run `clean-git --force`. No matter what I try, the branches are being dropped in git.

Any advice will be greatly appreciated. I've been struggling with this for the better part of 4 days now.

4 answers

1 accepted

0 votes
Answer accepted
kgleason January 23, 2014

What I ended up doing is migrating folder by folder (each folder was going to be it's own repo anyhow). I left this folder for last, and tweaked it to make the layout more standard. I ended up getting it to work.

I kind of blindly accepted the "Atlassian way" in that article, and in hindsight, I wish I had done a bit more research about it.

Anyhow, all's well that ends well.

1 vote
Yannick Biet March 22, 2019

Same for me in March 2019. I have try on multiple repos. I can see remote branches in git after migration.

 

Trying to use clean-git is telling me that it will create local branches but as soon as i use --force option, the output is slightly different and adds :

# Checking for obsolete branches...
Deleting Git branch 'origin/tags/1.3.0.145' not in Subversion.
Deleted branch origin/tags/1.3.0.145 (was dea7a49).
Deleting Git branch 'origin/tags/1.1.0.102' not in Subversion.
Deleted branch origin/tags/1.1.0.102 (was 40eaa42).
Deleting Git branch 'origin/del-nuget-exe' not in Subversion.
Deleted branch origin/del-nuget-exe (was aca2d46).
Deleting Git branch 'origin/feat-si-atelier-proxy' not in Subversion.
Deleted branch origin/feat-si-atelier-proxy (was 947919d).
Deleting Git branch 'origin/tags/1.1.4.115' not in Subversion.
Deleted branch origin/tags/1.1.4.115 (was 8f2b462).
Deleting Git branch 'origin/tags/1.1.1.105' not in Subversion.
Deleted branch origin/tags/1.1.1.105 (was 2783e61).
Deleting Git branch 'origin/fix-tracking-gpao' not in Subversion.
Deleted branch origin/fix-tracking-gpao (was 14f7d82).
Deleting Git branch 'origin/trunk' not in Subversion.
Deleted branch origin/trunk (was 6bdfbe1).
Deleting Git branch 'origin/tags/1.1.2.107' not in Subversion.
Deleted branch origin/tags/1.1.2.107 (was 31aac71).
Deleting Git branch 'origin/tags/1.2.0.120' not in Subversion.
Deleted branch origin/tags/1.2.0.120 (was 4f830ce).
Deleting Git branch 'origin/tags/1.1.3.111' not in Subversion.
Deleted branch origin/tags/1.1.3.111 (was a7bcf32).
Deleting Git branch 'origin/tags/1.1.0.103' not in Subversion.
Deleted branch origin/tags/1.1.0.103 (was ca7179b).
Barksdale Trading Group May 21, 2019

Hey Yannick,

 

I am moving some SVN repos to git and i have the exact same issue.  Have you found a solution?

Yannick Biet June 5, 2019

Hello,

 

sorry for the delay. in deed i have found another solution using svn2git tool :
https://github.com/nirvdrum/svn2git

 

This clone the SVN repo as git and then you can use Atlassian clean-git script to clean branches and tag names.

 

Try a look

0 votes
Ashish Bansal October 29, 2018

I am facing the same issue ... seems jar ~/svn-migration-scripts.jar clean-git --force is deleting branches and Tags

0 votes
cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 8, 2014

Hi Kirk,

I'm sorry to hear that.

Honestly, given how little work the clean-git command actually does I would just skip that step. It's basically an implementation of some of the scripts in the following blog post:

http://blogs.atlassian.com/2012/01/moving-confluence-from-subversion-to-git/

Depending on which parts of the cleanup you need feel free to run them manually. The only one you really need is to convert the SVN remote branches into normal Git branches (see "Create the final branches").

Let me know how you go.

Charles

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events