git svn as a crutch for svn merging woes
Consider an svn repository that has branches that are not necessarily located in the usual trunk/tags/branches layout. I want to persuade git-svn to take two of those branches on board, plus whatever else it needs, so that I can use git as a merge tool to avoid various levels of heck that have been plaguing us with svn merging. If the开发者_开发知识库 branches are all in one place, there's --branches
, but is there a way if they are not?
Do your git svn init ROOT_URL
, then go in and edit your .git/config
to add additional fetch
lines:
[svn-remote "svn"]
url = https://svn.mcs.anl.gov/repos/mpi
fetch = mpich2/trunk:refs/remotes/trunk
fetch = mpich2/branches/dev/threads:refs/remotes/threads
fetch = mpich2/branches/dev/knem:refs/remotes/knem
fetch = mpich2/branches/release/MPICH2_1_0_8:refs/remotes/mpich2-1.0.8
Then git fetch
and you should get all of the branches explicitly listed in your config file.
Be aware, however, that you may not want to actually pursue merging externally via git-svn
. Git won't maintain the svn:mergeinfo
properties for you, which will make going back to a native SVN-based merge workflow nearly impossible. You might also confuse git-svn
quite a bit by cherry-picking or merging code that has already been committed to the actual SVN repo, since it searches for git-svn-id:
"breadcrumbs" in the commit messages in order to figure out which SVN path should be used for git svn dcommit
. See the CAVEATS
section of the git-svn man page for additional info about this.
FWIW, I've also posted about this in longer form on my own site.
精彩评论