What is the correct way to convert SVN remote branches and tags into local Git branches/tags during SVN to Git migration

后端 未结 5 644
庸人自扰
庸人自扰 2020-12-30 15:00

What is the correct way to make the remote branches/tags that exist after a git-svn init/git-svn fetch into local Git branches/tags before pushing to my remote Git repo and

5条回答
  •  感情败类
    2020-12-30 15:40

    For a one-shot operation like this, before leaving behind a SVN repo, I like to clone it using the ruby script svn2git

    === Examples

    Say I have this code in svn:

      trunk
        ...
      branches
        1.x
        2.x
      tags
        1.0.0
        1.0.1
        1.0.2
        1.1.0
        2.0.0
    

    git-svn will go through the commit history to build a new git repo.
    It will import all branches and tags as remote svn branches, whereas what you really want is git-native local branches and git tag objects.
    So after importing this project I'll get:

      $ git branch
      * master
      $ git branch -a
      * master
        1.x
        2.x
        tags/1.0.0
        tags/1.0.1
        tags/1.0.2
        tags/1.1.0
        tags/2.0.0
        trunk
      $ git tag -l
      [ empty ]
    

    After svn2git is done with your project, you'll get this instead:

      $ git branch
      * master
        1.x
        2.x
      $ git tag -l
        1.0.0
        1.0.1
        1.0.2
        1.1.0
        2.0.0
    

提交回复
热议问题