Difference between revisions of "Converting the SVN Repository To Git"

From Net-SNMP Wiki
Jump to: navigation, search
(Branch Merging Setups)
(Small Cleanups)
Line 40: Line 40:
 
* delete the svn-remote and svn sections of the .git/config
 
* delete the svn-remote and svn sections of the .git/config
 
* git gc --aggressive
 
* git gc --aggressive
 +
 +
== Converting to a bare repo ==
 +
 +
# mv .git ../new-repo.git
 +
# cd ../new-repo.git
 +
# git config --bool core.bare true
 +
 +
== Adding Hooks ==
 +
 +
* place the hook from [http://sourceforge.net/apps/trac/sourceforge/wiki/Git%20hook%20script%20example here] into hooks/post-receive
 +
# git config hooks.mailinglist net-snmp-cvs@lists.sourceforge.net
  
 
[[Category:Git]]
 
[[Category:Git]]
 
[[Category:History]]
 
[[Category:History]]

Revision as of 05:21, 28 June 2011

This page documents what was done to convert the Net-SNMP source code repository from SVN to Git on June 27th, 2011. It is here for historical purposes, and may help other projects that wish to do the same conversion.

svn2git

Of the various conversion choices (including 'git svn clone'), svn2git seemed like it would work the best. So this was run:

 # svn2git --authors /home/hardaker/src/snmp/git-authors -m -v file:///home/hardaker/lib/sf-bkups/net-snmp-convert-svnrepo/

(this process takes a long time but is much faster with a local repository which is a copy of the data pulled from SourceForge. It only took about 4 hours to convert compared to many more that it would have taken to run it against an online repo)

Narrowing to the right sub-repo

With SVN the various "projects" (httpd, net-snmp, ...) existed at the top level. This isn't correct for the now separated repositories that git allows for. Thus, git's filter-branch was used to narrow the results:

 # git filter-branch --subdirectory-filter net-snmp -- --all

Branch Merging Setups

In order to make it possible to follow the project's Git Branch Management strategies, the branches had to be set up to follow this paradigm. To do this, the following steps were performed. This step ensure that future merges from lower branches would only contain the newer code choices and that from a "future merges" perspective everything previous to this point would have been considered as "already merged".

# git checkout V5-1-patches
# git merge -s ours V5-0-patches
# git checkout V5-2-patches
# git merge -s ours V5-1-patches
# git checkout V5-3-patches
# git merge -s ours V5-2-patches
# git checkout V5-4-patches
# git merge -s ours V5-3-patches
# git checkout V5-5-patches
# git merge -s ours V5-4-patches
# git checkout V5-6-patches
# git merge -s ours V5-5-patches
# git checkout master
# git merge -s ours V5-6-patches

Small Cleanups

  • git config receive.denyNonFastforwards true
  • git config core.sharedrepository 1
  • delete the svn-remote and svn sections of the .git/config
  • git gc --aggressive

Converting to a bare repo

# mv .git ../new-repo.git
# cd ../new-repo.git
# git config --bool core.bare true

Adding Hooks

  • place the hook from here into hooks/post-receive
# git config hooks.mailinglist net-snmp-cvs@lists.sourceforge.net