I have finally discovered what I need to do in order to work with SVN branches using Git.
I have tried the stuff mentioned below (except where I specify) so I am fairly confident that as long as I don't do anything funny or out of line, my commits from Git to SVN should work just fine. But of course I don't take any responsibility for any problems that might occur! I am open for further comments / remarks.
Even if I don't clone the SVN repo with the standard layout, I should have remotes configured that are pointing to the relevant SVN paths on subversion.
To clone a SVN branch (the SVN path should be pointing to the root path containing trunk, branches and tags):
git svn clone -s http://myrepo.com c:/my/local/path
If you are already have a clone of an SVN branch you need to manually add remotes to other SVN branches, check these out:
What is important is that you have a local branch that is tracking the remote branch.
git checkout -b localbranch remotes/remote_branch
Now you can commit against that local branch and each time when done do this just like in trunk:
git svn fetch
git svn dcommit
When you are finally done with that SVN branch and you would like to merge to trunk, you can do the following (it takes everything from that branch and rebases it into master):
git checkout master
git merge localbranch
git rebase -i trunk (just save the message)
git svn fetch
git svn dcommit
You can also just do a squash merge if you want to (if you don't want to bring all those little check-ins accross):
git merge --squash localbranch
git svn fetch
git svn dcommit
You might be doing a dry-run before doing a real DCOMMIT to make sure everything is fine (including the destination).
git svn dcommit -dry-run
However, if you anticipate merge conflicts (this is what I read on the web but I haven't tried it which I'm just mentioning) do the following before the git checkout master
line shown above. This is a local branch that doesn't track the remote branch which should be used to tackle merge conflicts and stuff. Whether this is necessary is another story.
git checkout -b merge_work master
git merge localbranch
git checkout master
git rebase merge_work
I'm writing this down for myself and for other people who might want to try this in the future.