I want to convert a Subversion repository sub-directory (denoted by module
here) into a git repository with full history. There are many svn copy
opera
[This is the original poster speaking writing. The below used to be update to the question, but as it solved the case - albeit unsatisfactorily to my taste - I will post it as an answer lacking a better solution.]
I do not like this, but I ended up doing clone
splitted into init
and fetch
with some editing of .git/config
between (repopath=apps/module
, gitreponame=module
):
$ git svn init--username=mysvnusername \
--branches=/src/branches/ \
--trunk=/src/trunk/${repopath} \
--tags=/src/tags/ \
http://svnserver/svn/src ${gitreponame}
$ cd ${gitreponame}
$ sed -i.bak "s|*:|*/${repopath}:|" .git/config
$ git svn fetch --authors-file=../authors.txt --follow-parent
I could not find how to specify the branches for subdirectory migration with git svn
- hence the editing of the .git/config
file. The following unified diff illustrates the effect of the editing with sed
:
[svn-remote "svn"]
url = http://svnserver/svn/src
fetch = trunk/apps/module:refs/remotes/trunk
- branches = branches/*:refs/remotes/*
- tags = tags/*:refs/remotes/tags/*
+ branches = branches/*/apps/module:refs/remotes/*
+ tags = tags/*/apps/module:refs/remotes/tags/*
As the actual desired HEAD
was in an another URL, I ended just adding another [svn-remote]
section to .git/config
:
+ [svn-remote "svn-newest"]
+ url = http://svnserver/svn/src
+ fetch = branches/x/y/apps/module:refs/remotes/trunk
+ branches = branches/*/apps/module:refs/remotes/*
+ tags = tags/*/apps/module:refs/remotes/tags/*
(in real life experiment I also added here some branches that were not picked up by the first fetch), and fetching again:
$ git svn fetch --authors-file=../authors.txt --follow-parent svn-newest
This way I ended having the full Subversion history migrated to the newly generated git repository.
Note-1 : I probably could have just told my "trunk" to be branches/x/y/apps/module
as the meaning of "trunk" for git-svn
seems to basically have the meaning of git HEAD
(Subversion concepts of trunk, branches, tags have no deep technical basis, they are matter of socially agreed convention).
Note-2 : probably --follow-parent
is not required for git svn fetch
, but I have no way of knowing or experimenting now.
Note-3 : While earlier reading of svn2git which seems to be a wrapper over git-svn
I failed to see the motivation, but seeing the messy presentation of tags I kind of get it now. I would try svn2git
next time if I had to try doing this again.
P.S. This is rather awkward way of doing the operation. Secondary problem here (why the editing of the .git/config
by external was required) seems to be that
git svn
implementation strictly assumes the social Subversion conventions to be followed to a degree (which is not possible if you just want to migrate a subdirectory and not the whole Subversion repository).TODO: It would be helpful to have the format of the .git/config
file explained here as it relates to git svn
- for example I have now (after one and half year of writing the original answer) no idea what the [svn-remote "svn-newest"]
means above. Also the approach could be automated by writing a script, but this is beyond my current interest in the problem and I do not have access to the original Subversion repository or replication of the issue.