简体   繁体   English

谷歌代码存档到 Github

[英]Google Code Archive to Github

I want to migrate this project https://code.google.com/archive/p/majesticuo to GitHub maintaining the history.我想将此项目https://code.google.com/archive/p/majesticuo迁移到 GitHub 以维护历史记录。

When i try to use the 'Export to GitHub' button, it says 'The Google Code project export tool is no longer available当我尝试使用“导出到 GitHub”按钮时,它显示“Google 代码项目导出工具不再可用

The Google Code to GitHub exporter tool is no longer available. Google Code to GitHub 导出器工具不再可用。 The source code for Google Code projects can now be found in the Google Code Archive.' Google Code 项目的源代码现在可以在 Google Code Archive 中找到。

What would be the best way to do it manually?手动执行此操作的最佳方法是什么? I have no svn knowledge and know a little bit of git.我没有 svn 知识,也知道一点 git。 Thanks so much!非常感谢!

Updated 06 Nov 2017 2017 年 11 月 6 日更新

It appears that you can recover and download the project's history in form of gzipped svn dump stream file.您似乎可以以 gzip 压缩的 svn 转储流文件的形式恢复和下载项目的历史记录。 Follow these steps:请按照以下步骤操作:

  1. Navigate to the Google Code archive page for the project.导航到项目的 Google 代码存档页面。 Eg https://code.google.com/archive/p/majesticuo/例如https://code.google.com/archive/p/majesticuo/
  2. Copy the download URL under Source.复制源下的下载 URL。
  3. In the URL, change source-archive.zip to repo.svndump.gz and download the file.在 URL 中,将source-archive.zip更改为repo.svndump.gz并下载文件。

Example URL:示例网址:

https://storage.googleapis.com/google-code-archive-source/v2/code.google.com/majesticuo/repo.svndump.gz

The file is a gzipped svn repository dump stream file and you can use svnadmin load tool to load it into a new repository.该文件是一个 gzip 压缩的 svn 存储库转储流文件,您可以使用svnadmin load工具将其加载到新存储库中。

If you navigate to your project's page in Google Code, then click on "Source" in the sidebar, and then click on "source" inside the resulting page, you'll be taken to a page with a "Download" link.如果您在 Google Code 中导航到您的项目页面,然后单击侧栏中的“源”,然后在结果页面中单击“源”,您将被带到带有“下载”链接的页面。 That will lead to a file called "source-archive.zip", which contains some sort of archive of your project--I'm not sure how complete that it, but it does contain some svn metadata.这将导致一个名为“source-archive.zip”的文件,其中包含您项目的某种存档——我不确定它有多完整,但它确实包含一些 svn 元数据。 However, if change the last part of that URL from "source-archive.zip" to "repo.svndump.gz", you'll get an svn "dump" of your repo.但是,如果将该 URL 的最后一部分从“source-archive.zip”更改为“repo.svndump.gz”,您将获得您的 repo 的 svn“dump”。 That should contain the full history and be convertible to git format with various svn-to-git migration tools.这应该包含完整的历史记录,并且可以使用各种 svn-to-git 迁移工具转换为 git 格式。 (I figured that out based on information in this blog post , which also lists some suggested steps for the final conversion. But if your first attempt at converting the dump fails, try other tools; there are many options and there's a bit of an art to it if your repo history is complicated.) (我根据这篇博文中的信息得出了这一点,其中还列出了一些最终转换的建议步骤。但是如果您第一次尝试转换转储失败,请尝试其他工具;有很多选择,而且有点艺术如果您的回购历史记录很复杂,则可以使用它。)

Here is the procedure I performed lately to move Google Code archive of gil-contributions to GitHub repo , locally without any instance of Subversion server.这是我最近执行的将gil-contributions 的Google Code 存档移动到 GitHub repo 的过程,本地没有任何 Subversion 服务器实例。

  1. Follow bahred's explained to download the repo.svndump.gz archive.按照bahred 的解释下载repo.svndump.gz存档。

  2. Create local Subversion repository and import the dump创建本地 Subversion 存储库并导入转储

    svnadmin create /home/mloskot/svn svnadmin load /home/mloskot/svn < /home/mloskot/repo.svndump
  3. Checkout the Subversion repo to generate the authors file签出 Subversion 存储库以生成作者文件

    svn checkout file:///home/mloskot/svn

    and find one of many scripts to generate the authors.txt .并找到许多脚本之一来生成authors.txt

  4. Download latest SubGit from https://subgit.comhttps://subgit.com下载最新的 SubGit

  5. Read the SubGit importing guide, https://subgit.com/documentation/import-book.html阅读 SubGit 导入指南, https: //subgit.com/documentation/import-book.html

  6. Initialize the Git repo where SubGit will translate the Subversion repo初始化 Git 存储库,其中 SubGit 将转换 Subversion 存储库

    subgit configure --minimal-revision 1 --layout std file:///home/mloskot/svn /home/mloskot/git
  7. Edit the subgit/config file generated in /home/mloskot/git/subgit/config编辑/home/mloskot/git/subgit/config生成的subgit/config文件

  8. Import the Subversion repo into Git将 Subversion 存储库导入 Git

     subgit import /home/mloskot/git subgit uninstall --purge /home/mloskot/git
  9. Clone the Git repo, also as a verification step, and push it to GitHub克隆 Git 存储库,也作为验证步骤,并将其推送到 GitHub

     git clone --mirror /home/mloskot/git repo cd repo git config remote.origin.mirror false git clone --mirror <GITHUB REPO URL> git remote set-url origin <GITHUB REPO URL> git push --all origin git push --tags origin
  10. Enjoy your code's new home!享受您的代码的新家!

Cherry-picking (heh!)樱桃采摘(嘿!)

  1. from bahrep's/JiriHnidek's reply for downloading the gzipped SVN "image",来自bahrep's/JiriHnidek's对下载压缩后的 SVN“图像”的回复
  2. from mloskot's reply for svnadmin use,来自mloskotsvnadmin使用的回复
  3. and Coleman Corrigan's reply describing how to use Git to import from SVN,Coleman Corrigan 的回复描述了如何使用 Git 从 SVN 导入,

here are the steps I took with a project name $PROJECT archived at https://code.google.com/archive/p/$PROJECT :以下是我使用存档在https://code.google.com/archive/p/$PROJECT的项目名称$PROJECT采取的步骤:

wget https://storage.googleapis.com/google-code-archive-source/v2/code.google.com/${PROJECT}/repo.svndump.gz
svnadmin create p
time zcat repo.svndump.gz|svnadmin load p
git svn init file://$(pwd)/p --stdlayout ${PROJECT}
cd ${PROJECT}
time git svn fetch --all
git remote add origin https://github.com/${USER}/${PROJECT}
git fetch origin
time git push -u origin master
cd ..
rm -rf p repo.svndump

Just tested the accepted answer today and got the following error:今天刚刚测试了接受的答案并得到以下错误:

"Access denied. Anonymous caller does not have storage.objects.get access to google-code-archive-source/v2/code.google.com//repo.svndump.gz." “访问被拒绝。匿名调用者没有 storage.objects.get 访问 google-code-archive-source/v2/code.google.com//repo.svndump.gz。”

There is, however, a way to import it to git, including the commit history:但是,有一种方法可以将其导入 git,包括提交历史记录:

  • Download the "source-archive.zip" file using the provided button/url;使用提供的按钮/网址下载“source-archive.zip”文件;
  • Use the hg-git Mercurial extension to convert it to a git repository (instructions for Windows can be found here ).使用 hg-git Mercurial 扩展将其转换为 git 存储库(可在此处找到适用于 Windows 的说明)。

I just did it using an empty GitHub repository (created just for that, no README.md file) and it worked on the first try.我只是使用一个空的 GitHub 存储库(为此创建的,没有 README.md 文件)完成了它,并且在第一次尝试时就成功了。 The hg-git extension will generate a local branch on your git repo called "hg" that can be pushed to your Github remote. hg-git 扩展将在您的 git 存储库上生成一个名为“hg”的本地分支,可以推送到您的 Github 远程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM