Page tree
Skip to end of metadata
Go to start of metadata
  1. Install SubGit tool according to the Installation guide.

  2. Configure GitHub

    • Log in to GitHub and create a new repository:


     
  3. Configure the local repository:

    Run the command below on behalf of the same user you use to serve Git repository:

    $ subgit configure --layout auto --trunk TRUNK SVN_URL GIT_REPO

    where

    • SVN_URL   – URL to the SVN project.
    • GIT_REPO  – a path to the new Git repository where data from the SVN project will be imported to.
    • TRUNK     – a path, relative to SVN_URL, that leads to an SVN directory that plays the role of the main line of development.
       

       see the configuration command example.
      subgit configure example
      $ subgit configure --layout auto --trunk trunk http://svn.example.com/svn/repository/project /home/user/project.git
      
                  SubGit version 3.2.4 ('Bobique') build #3670
      
                  Configuring writable Git mirror of remote Subversion repository:
                      Subversion repository URL : http://svn.example.com/svn/repository/project
                      Git repository location   : ./project.git
      
                  Git repository is served by GitLab, hooks will be installed into 'custom_hooks' directory.
      
                  Detecting peg location...
                  Authentication realm: <http://svn.example.com/:80> Subversion Repository
                  Username [git]: user
                  Password for 'user':
                  Peg location detected: r10248 project/trunk
                  Fetching SVN history... Done.
                  Growing trees... Done.
                  Project origin detected: r1 project/trunk
                  Building branches layouts... Done.
                  Combing beards... Done.
                  Generating SVN to Git mapping... Done.
      
                  CONFIGURATION SUCCESSFUL
      
                  To complete SubGit installation do the following:
      
                  1) Adjust Subversion to Git branches mapping if necessary:
                      /var/opt/gitlab/git-data/repositories/user/project.git/subgit/config
                  2) Define at least one Subversion credentials in default SubGit passwd file at:
                      /var/opt/gitlab/git-data/repositories/user/project.git/subgit/passwd
                     OR configure SSH or SSL credentials in the [auth] section of:
                      /var/opt/gitlab/git-data/repositories/user/project.git/subgit/config
                  3) Optionally, add custom authors mapping to the authors.txt file(s) at:
                      /var/opt/gitlab/git-data/repositories/user/project.git/subgit/authors.txt
                  4) Run SubGit 'install' command:
                      subgit install ./project.git
    • Enable post-receive hook:

      $ git config -f GIT_REPO/subgit/config svn.triggerSvnPostReceive true

      where

      • GIT_REPO  – a path to the new Git repository where data from the SVN project will be imported to.
         
    • Specify authors mapping

      Configure authors mapping in default authors mapping file:

      GIT_REPO/subgit/authors.txt 

      Or change core.authors option so that it points to the global authors mapping file.

      Find more details about authors mapping in the Authors mapping article.


    • Specify a username and password that are used by SubGit to access the SCN repository. Edit passwd file:

      GIT_REPO/subgit/passwd

      By default, there's only subgit secret credential pair. Replace it with a username and its corresponding password.

      SVN authentication

      There are several methods to configure authentication to access SVN server, but we use a plain text password file here to simplify the guide. See more authentication methods in SVN Authentication if this method does not fit your needs.

  4. Perform SubGit installation into local Git repository:

    $ subgit install GIT_REPO

    where 
       GIT_REPO  – a path to the new Git repository where data from the SVN project will be imported to.

     See subgit install example…
    subgit install
    $ subgit install /home/user/repo.git
    
      SubGit version 3.2.4 ('Bobique') build #3670
    
      Translating Subversion revisions to Git commits...
    
      Subversion revisions translated: 10248.
      Total time: 2 hours 15 minutes 23 seconds.
    
      INSTALLATION SUCCESSFUL
    
      Your copy of SubGit is not registered for repository at '/home/user/repo.git'.
    
      Obtain registration key at http://www.subgit.com/ and register SubGit with 'register' command;
      registration is free for Open Source, Educational and Startup projects.
    
      To uninstall SubGit use 'uninstall' command.
  5. Sync local Git repository with GitHub:

    • step into newly created local Git repository 

      $ cd GIT_REPO
    • add a remote to the local Git repository:

      $ git remote add github GITHUB_REPO

      where 

      • GITHUB_REPO – GitHub project URL.


    • enable caching your GitHub password in Git:
      • in Linux:

        $ git config --global credential.helper cache
      • in MacOS X:

        $ git config --global credential.helper osxkeychain
    • push local repository content into GitHub repository:

       See git push command…
      git push
      $ git push github --all --follow-tags --force
       See git push example…
      git push
      $ git push github --all --follow-tags --force
      
      Username for 'https://github.com': user
      Password for 'https://user@github.com': 
      Counting objects: 212, done.
      Delta compression using up to 2 threads.
      Compressing objects: 100% (193/193), done.
      Writing objects: 100% (212/212), 19.24 KiB | 0 bytes/s, done.
      Total 212 (delta 109), reused 0 (delta 0)
      remote: Resolving deltas: 100% (109/109), done.
      To https://github.com/user/project.git
       * [new branch]      Lib_test -> Lib_test
       * [new branch]      ano_branch -> ano_branch
       * [new branch]      another_full -> another_full
       * [new branch]      br_rev31 -> br_rev31
       * [new branch]      br_rev33 -> br_rev33
       * [new branch]      br_rev35 -> br_rev35
       * [new branch]      br_rev37 -> br_rev37
       * [new branch]      branch_rev27 -> branch_rev27
       * [new branch]      branch_rev27_1 -> branch_rev27_1
       * [new branch]      bugs/b_4517 -> bugs/b_4517
       * [new branch]      bugs/rev39_b1 -> bugs/rev39_b1
       * [new branch]      bugs/rev39_b2 -> bugs/rev39_b2
       * [new branch]      feat_4489 -> feat_4489
       * [new branch]      features/feat_4510 -> features/feat_4510
       * [new branch]      features/feat_5612 -> features/feat_5612
       * [new branch]      features/feat_5614 -> features/feat_5614
       * [new branch]      features/rev39_f1 -> features/rev39_f1
       * [new branch]      features/rev39_f2 -> features/rev39_f2
       * [new branch]      full_branch -> full_branch
       * [new branch]      john_br -> john_br
       * [new branch]      master -> master
       * [new branch]      new_branch -> new_branch
       * [new branch]      snapshots/rev39_s1 -> snapshots/rev39_s1
    • create post-receive hook script and make it executable:

      $ echo 'git push --all --follow-tags github' > GIT_REPO/hooks/user-post-receive
      $ chmod ug+x GIT_REPO/hooks/user-post-receive

    Mirroring limitation

    In order to maintain a reliable two-way mirror using the setup described above, Git users have to push their changes to the SubGit-managed Git repository rather than submitting changes to the GitHub repository directly. 

  6. Try and buy.

    Trial period

    Note: the trial period for SubGit mirror is 30 days, after that period you should buy a license key at https://subgit.com/pricing

    Once you receive an email with a license key, upload this license key to your server and run the following command:

    $ sudo subgit register --key subgit.key GIT_REPO

    where

         GIT_REPO – a path to your newly created Git repository.

     Subgit register example…
    subgit register
    $ sudo subgit register --key subgit.key /home/user/repo.git
    
       SubGit version 3.2.4 ('Bobique') build #3670
    
       Registration information:
    
         Registered for:       Example company
         Purchase ID:          OS-111111111111111
         Expiration date:      April 23, 2028
    
         You may use this key to register 9 more repositories (out of 10).
    
       REGISTRATION SUCCESSFUL
    
       Thank you for registering SubGit!
       Visit http://www.subgit.com/ in case you have any questions and for more information on SubGit.
  7. Get support.

    If you have encountered any problems, see the following guides for more details:

     

Should you need any assistance, don't hesitate to contact us at support@tmatesoft.com.