How do I migrate an SVN repository with history to a new Git repository?

前端 未结 30 1994
离开以前
离开以前 2020-11-22 02:51

I read the Git manual, FAQ, Git - SVN crash course, etc. and they all explain this and that, but nowhere can you find a simple instruction like:

SVN repository in: <

30条回答
  •  無奈伤痛
    2020-11-22 03:38

    I´m on a windows machine and made a small Batch to transfer a SVN repo with history (but without branches) to a GIT repo by just calling

    transfer.bat http://svn.my.address/svn/myrepo/trunk https://git.my.address/orga/myrepo

    Perhaps anybody can use it. It creates a TMP-folder checks out the SVN repo there with git and adds the new origin and pushes it... and deletes the folder again.

    @echo off 
    SET FROM=%1 
    SET TO=%2 
    SET TMP=tmp_%random%
    
    echo from:  %FROM% 
    echo to:    %TO% 
    echo tmp:   %TMP%
    
    pause
    
    git svn clone  --no-metadata --authors-file=users.txt %FROM% %TMP%  
    cd %TMP% 
    git remote add origin %TO% 
    git push --set-upstream origin master
    
    
    cd .. 
    echo delete %TMP% ... 
    pause
    
    rmdir /s /q %TMP%
    

    You still need the users.txt with your user-mappings like

    User1 = User One 
    

提交回复
热议问题