How to set up Git/SVN Mirror
This is a quick how-to on how to set up Git/SVN mirror. It will be sufficient to follow steps below for most of the standard SVN repositories to create a writable Git mirror of SVN project. For more comprehensive documentation refer to SubGit Book.
Table of Contents
1. Configure Mirror Git Repository
2. Review and Adjust Git/SVN Mirror Configuration
3. Perform Initial Translation
4. Perform One-Time Import
4. System Requirements
5. SubGit with GitLab
6. Moving Git Repository
7. Get Support
1. Configure Mirror Git Repository
Run the following command to configure Git repository to mirror SVN project:
$ subgit configure --layout auto --trunk trunk SVN_PROJECT_URL repos.git
Above command will detect branches layout in the SVN project and then will create empty bare Git repository ready to mirror SVN project. You may be asked for credentials unless those are already stored in the SVN credentials cache at ~/.subversion directory.
To get help on any of the SubGit commands run:
$ subgit help COMMAND_NAME
e.g.
$ subgit help configure
2. Review and Adjust Git/SVN Mirror Configuration
Review and adjust branches mapping configuration:
$ edit repos.git/subgit/config
Review and adjust Git/SVN authors mapping:
$ edit repos.git/subgit/authors.txt
You may use dynamic authors mapping replacing authors.txt with a script. Script sample could be found at repos.git/subgit/samples directory.
3. Perform Initial Translation
Run the following command to enalbe mirror and translate SVN revisions to Git commits:
$ subgit install repos.git
As soon as initial translation is completed, repos.git is ready to serve users. Pushes to repos.git will be translated to SVN and commits to SVN will be translated to Git.
Note, that repos.git is so called ‘bare’ Git repository, i.e. it does not contain working tree. One would need to configure a server so that remote users are able to access this bare repository to clone it and push changes back.
For a comprehensive guide on how to set up Git server check Git on the Server documentation page.
4. Perform One-Time Import
In case you only need to do one-time import from SVN to Git, use ‘import’ command to perform import:
$ subgit import repos.git
In case of one-time import, repos.git will not be kept in sync with SVN project.
Note, that repos.git is so called ‘bare’ Git repository, i.e. it does not contain working tree. One would need to configure a server so that remote users are able to access this bare repository to clone it and push changes back.
For a comprehensive guide on how to set up Git server check Git on the Server documentation page.
5. System Requirements
We test SubGit on Linux, Windows and OS X. JDK 1.7 or newer is required. SVN servers 1.4 or newer are supported.
6. SubGit with GitLab
If you’re using GitLab refer to GitLab How-to for more information on how to set up SubGit to work seamlessly with GitLab.
7. Moving Git Repository
Would you need to move Git repository in filesystem, you’d need to shutdown sync before move and enable it back after repository has been moved:
$ subgit shutdown repos.git
$ mv repos.git repos2.git
$ subgit install repos2.git
7. Get Support
For support feel free to contact us at support@subgit.com. We are ready to help!