NOTE: This question is inspired by the git-svn branching question and NOT a duplicate!
Without doing anything extraordinary when I checked out our svn-repo I got the following .git/config file:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
autocrlf = false
[svn-remote "svn"]
url = svn+ssh://my_server/opt/subversion/main/trunk
fetch = :refs/remotes/git-svn
[color]
ui = true
When I try to use git svn branch I get the message:
Unknown branch destination
The reason for this is that branches is missing in .git/config. I whant the branches to go into a directory parallel to trunk. So for example a branch named foo should be found at this path:
svn+ssh://my_server/opt/subversion/main/branches/foo
If I am working in a separate branch made inside of git with git checkout -b foo, I then want to create the branch in subversion with:
git svn branch foo
How do I update .git/config to get this working? I would be expecting a message like the following from git svn branch foo:
Copying svn+ssh://my_server/opt/subversion/main/trunk at r8507 to svn+ssh://my_server/opt/subversion/main/branches/foo...
Edit:
What if I update the svn-remote section to:
[svn-remote "svn"]
url = svn+ssh://my_server/opt/subversion/main
fetch = trunk:refs/remotes/git-svn
branches = branches/*:refs/remotes/branches/*
It looks like its the right thing to do and seems to be working when I have tried to do git svn rebase and git svn branch. Is this a working solution or will I mighty pile of mess if I work with this new config a while?
You have a problem, because your svn-remote.svn.url is not the root of the repository and to fetch multiple branches it has to be. You can just change it and run fetch, but I am not sure git-svn can use the data it already has in such case. It won't be worse than re-cloning in any case.
Your config has to look like. When cloning, you get that by using the -t trunk option.
[svn-remote "svn"]
url = svn+ssh://my_server/opt/subversion/main
fetch = trunk:refs/remotes/trunk
By default, trunk will go directly to remotes, but you can insert some name between, which is cleaner if you also have other remotes. I usually have refs/remotes/svn/trunk.
If you provided the -b option, you will also have
branches = branches/*:refs/remotes/branches/*
but if you didn't, you can add it manually anytime. That's what you need to have to be able to import branches and to create branches.
Last the -T option would add
tags = tags/*:refs/remotes/tags/*
which you can again add anytime later. Note though, that svn tags won't behave as git tags, they will still behave as branches.
For convenience the -s option to clone is shorthand for -t trunk -b branches -T tags.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With