Reputation: 1
I am trying to load out company svn repo into git using git-svn, but sadly one of my coworkers created a branch with illegal characters (\) in the branch name. Now, when I'm trying to import the whole history, git exits with an error:
fatal: Cannot lock the ref 'refs/remotes/feature-\\-bar'.
update-ref -m r4 refs/remotes/feature-\\-bar 471d9622546803b3712a436c2e2ed6b1490c829a: command returned error: 128
I could do without the branch since it is way in the past anyway, but I do not want to loose all the history up to the point where the branch was merged. I tried the --ignore-path option, but I cannot get it to work, mainly because I suspect it only addresses paths inside the branch/trunk path (??). Does anyone know by any chance a way to resolve this issue?
Upvotes: 0
Views: 656
Reputation: 500
I had to do ignore some branches, too, because they were using illegal characters I could not fetch with git svn
(in my case the characters were :
and /
).
Solution 1: Manually add additional svn repositories for each branch
After initialising your repository with git svn init -s [svn-repository-url]
I commented the branch configuration in .git/config
out:
[svn-remote "svn"]
url = [svn-base-url]
fetch = [project-name]/trunk:refs/remotes/trunk
#branches = [project-name]/branches/*:refs/remotes/*
tags = [project-name]/tags/*:refs/remotes/tags/*
To add branches later on, I will do this by adding new svn locations for each branch, e.g.
[svn-remote "svn-your-branch"]
url = [svn-base-url]
fetch = [project-name]/branches/your-branch:refs/remotes/your-branch
Source: How do Git SVN ignore-paths work (ignoring daily build tags)? or with some actual configuration e.g. http://www.dmo.ca/blog/20070608113513/
Solution 2: Explicitly state the branches you like in your configuration
You can define the branches to fetch in .git/config
:
[svn-remote "svn"]
url = [svn-base-url]
fetch = [project-name]/trunk:refs/remotes/trunk
branches = [project-name]/branches/{your-branch-1|your-branch-2}:refs/remotes/*
tags = [project-name]/tags/*:refs/remotes/tags/*
If it is safe to add branches later on after having checkout out everything from svn, I will prefer this solution.
Source: https://stackoverflow.com/a/3844508/709431
Why does ignore-paths not work?
According to http://go-dvcs.atlassian.com/display/aod/Advanced+git-svn+options git svn --ignore-paths
only ignores the content of the commits. Thus, it will still create a ref for the branch name. This fails, if the branch name contains illegal characters. (Additionally, contrary to your assumption, ignore-paths
matches everything excluding the URL-part, e.g. with the configuration from above things like project-name/branches/your-branch-1
.)
Upvotes: 2
Reputation: 129594
I would start the git repo at the head of whatever branches are current - manually making the names of branches git-friendly. For older history import this way when needed. Sometimes it's just not worth the pain of importing svn history which follows a totally different mechanism all together.
Upvotes: 0