If you host many projects on single subversion repository & keep going for many years repo will grow for TBs & difficult to manage, Developers in each project may experience slowness. To avoid that we can use git to extract subversion projects separately and host again on subversion with repos for each project.
Here is the example....
Figure 1
Figure 2
MURALI & SANATH are servers that host Old subversion repository & New Subversion repository respectively as in Figure 2.
Note:
All commands should run on server SANATH
SANATH should contain following directory paths...
/data/gitrepo
/data/git2svn
/data/newsvnrepo
LDAP authentication used for each Legacy & New servers
Step 1
Make a copy of single project from Legacy subversion repository in to SANATH
> cd /data/gitrepo
> git svn clone http://murali.aepona.com/project/Zain/
This will create a folder /data/gitrepo/Zain with version information.
Step 2
Now the tricky backward engineering goes...
Create subversion repository on SANATH
> cd /data/newsvnrepo
> svnadmin create Zain
Host on Apache
<VirtualHost sanath.aepona.com:80>
ServerName sanath.aepona.com
<Location /Zain>
DAV svn
SVNPath /data/newsvnrepo/Zain
AuthType Basic
AuthName \"LDAP's Authorization\"
AuthUserFile /data/passwd
AuthzSVNAccessFile /data/svn.access
Require valid-user
</Location>
</VirtualHost>
Set permission
chown -R apache.apache /data/newsvnrepo/Zain
Now you should be able to browse the newly hosted svn repo on SANATH.
Follow the steps given below to accomplish the migration
> cd /data/git2svn
> git svn clone --username <New repo User> http://sanath.aepona.com/Zain
> cd Zain
> git fetch /data/gitrepo/Zain
> git branch tmp $(cut -b -40 .git/FETCH_HEAD)
> git tag -a -m "Last fetch" last tmp
> INIT_COMMIT=$(git log tmp --pretty=format:%H | tail -1)
> git checkout $INIT_COMMIT .
> git commit -C $INIT_COMMIT
> git rebase master tmp
> git branch -M tmp master
> git svn dcommit
Now you are done.
Cheers with following page.
There are few pros & cons...
Revision numbers are totally different from original source & User history gone.
But worth to have diffs.
Appreciate your input on this...
(Wrote a script for handle many projects, will upload near future...)
Script already written, but need to be customized with variables for public use. So will post script near future to accomplish more generalized needs.
ReplyDelete--FreeS/wan
I always said that it is no good idea to put multiple projects into the same repository. :D
ReplyDeleteI am only interested in step 2: Migrate from Git to SVN.
Is a git cloned repository much different to a SVN repository?
Is it possible to move a whole Git repository to a SVN repository with a single command like:
git svn clone --username svnuser http://server/app/trunk
Would be great if it is that simple. We plan to move all our projects from Git to SVN (for several reasons).
SVN 4 EVER!