问题 如何将Google Code上的SVN repo迁移到GitHub上的git repo


我很难从在code.google上托管的SVN存储库切换到github上的git repo。特别:

  1. 如何在保留修订历史记录的同时将code.google上的代码从SVN更改为GIT?
  2. 如何在保留修订历史记录的同时将code.google上的wiki从SVN更改为GIT?
  3. 如何将我的GIT存储库从code.google移动到GitHub?
  4. 如何使两个存储库保持同步,同时仍然使用GitHub作为主要存储库?

12774
2017-11-21 17:46


起源



答案:


变量:

  • $项目 是你的项目名称
  • $用户名 是你在github上的用户名

这假定你的 $项目 在github上的名称与在code.google上的名称相同,并且您已经初始化了github存储库。

此外,如果您的code.google存储库已经是GIT,则可以跳到第4步。

  1. 将项目从SVN转换为GIT。这就像进入Administration-> Source选项卡并将其从SVN更改为GIT一样简单。顺便说一句,在你这样做之后,svn仍然可用;所以不要担心完整的代码丢失。

  2. 将源代码从code.google SVN转换为code.google GIT(保留历史记录)

    git svn clone --stdlayout https://$project.googlecode.com/svn $project
    cd $project
    git remote add googlecode https://code.google.com/p/$project
    git push --all googlecode
    cd ..
    
  3. 将wiki从谷歌SVN转换为谷歌GIT(保持历史)

    git svn clone https://$project.googlecode.com/svn/wiki $project.wiki
    cd $project.wiki/
    git remote add googlecode https://code.google.com/p/$project.wiki
    git push --all googlecode
    cd ..
    
  4. 从github获取新的git repo

    mkdir github
    cd github/
    git clone https://code.google.com/p/$project.git
    cd $project/
    
  5. 从code.google GIT获取源代码到本地github克隆

    git remote set-url origin https://github.com/$username/$project.git
    git pull
    
  6. 将源从本地克隆推送到github

    git push origin master
    
  7. 告诉您的本地克隆将提交推送到github和code.google

    git remote set-url --add origin https://$project.googlecode.com/git
    
  8. 测试提交github和code.google的提交

    touch test.txt
    git add test.txt
    git commit -m "Testing repo replication" test.txt
    git push
    

现在,每当您对本地克隆进行更改时,它都会将这些更改推送到两个存储库。

注意:如果再次在另一个位置(如另一台计算机)进行克隆,则必须再次重复步骤6。


9
2017-11-21 17:46





Google Code上现在有一个导出功能 - 转到您项目的Google代码页,即 code.google.com/p/yourproject 然后你应该看到一个按钮 '导出到GitHub' 这将在几个步骤中完成(注意:您需要使用您的GitHub帐户进行授权)。

请注意,您可以执行此操作 任何 项目,而不仅仅是你自己的。


0
2017-07-04 00:02