how to convert svn repository to git on Windows

前端 未结 4 1295
陌清茗
陌清茗 2021-02-09 18:17

We have remote svn repository and we want it to convert to git. Could you please tell me how is it possible to do it on Windows? Thank.

4条回答
  •  鱼传尺愫
    2021-02-09 19:08

    Install application on Windows:

    • Git for Windows.
    • TortoiseGit

    Find out the svn repository URL and copy it

    Something like this:

    Invoke TortoiseGit Clone dialog

    Right click on destination folder, e.g. D:\SVN\ToGit, and Click Git Clone...

    Check the From SVN repository checkbox

    If you copied the URL first, then invoke the clone dialog, TortoiseGit will get the copied URL from clipboard and paste it into the URL text field for you. So, you don't paste it by yourself. Just have look at it to see if it's correct.

    And if you right click on destination folder, TortoiseGit also fill the Directory text field for you. Also, take a look to see if it's what you want.

    So, just check the From SVN repository checkbox.

    And if the svn repository has the standard layout, say trunk, tags, branches, you don't need to do anything further.

    Click the OK button to go

    Then, starting to clone a svn repository to git repository.
    Something like this:

    As you can see, TortoiseGit just properly uses Git for Windows command git svn clone to clone it.

    git.exe svn clone "svn://svn.code.sf.net/p/tortoisesvn/code/" "D:\SVN\ToGit\tsvn" -T trunk -b branches -t 
    

    So, basically, you can go Git Bash/CMD and re-use that command line, and also get the same result.

    NOTE: If you can see the r1, r2, r3..., you can stop the cloning anytime, and resume it later by using the same command line.


    Clone a local svn repository

    With TortoiseGit 2.4.4+

    Just copy the svn local path into URL of Clone dialog. See:

    Again, Check the From SVN repository checkbox

    Cloning:

    TortoiseGit 2.4.4+ will use file:/// protocol to clone a local svn repository.


    After you get a git repository, you can commit there. And push the commit back to origin svn repository by using TortoiseGit ->SVN DCommit..., something like svn commit.

    As you can see, the command is git svn dcommit.

    And if the origin svn repository has some new commit(s) need to update, you can use TortoiseGit ->SVN Rebase to fetch the svn commit and then merge/rebase on the latest commit. Something like svn update.

    It uses git svn fetch then uses git rebase to merge/rebase the fetched changes.

    For command line, you could just use git svn rebase.


    Read Pro Git v2 - Chapter 9 for more information and examples.

提交回复
热议问题