简体   繁体   English

将本地 svn repo 转储转换为 git

[英]Converting a local svn repo dump to git

I searched related questions but I couldn't find anything matching my specific situation: I have some old repository archives from an SVN server that was taken down years ago.我搜索了相关问题,但找不到与我的具体情况相符的任何内容:我有一些来自多年前被关闭的 SVN 服务器的旧存储库档案。 They're tarballs of the original repository structure on the server.它们是服务器上原始存储库结构的 tarball。 What I want to do is convert them to git repositories as a basis for future work/reviving the projects.我想做的是将它们转换为 git 存储库,作为未来工作/恢复项目的基础。 I've already read several tutorials about the conversion process, and I think I can figure out the authors conversion, branches mapping, etc., but they all assume you have an SVN server and a url for the repository.我已经阅读了几个关于转换过程的教程,我想我可以弄清楚作者转换、分支映射等,但它们都假设您有一个 SVN 服务器和一个存储库的 url。 Do I need to install and setup and SVN server to do this conversion, or is there some way I can point either git clone or svn2git (or another tool) at the repo dump I have?我是否需要安装和设置和 SVN 服务器来执行此转换,或者有什么方法可以将git clonesvn2git (或其他工具)指向我拥有的 repo 转储?

install subversion locally in order to import your dump, then with git-svn package.在本地安装 subversion 以导入您的转储,然后使用 git-svn 包。

You can use git svn clone file:///path/to/svn/repo /path/to/empty/dir你可以使用git svn clone file:///path/to/svn/repo /path/to/empty/dir

Retrieve a list of all Subversion committers :检索所有 Subversion 提交者的列表

svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt

Clone the Subversion repository using git-svn :使用 git-svn 克隆 Subversion 存储库

git svn clone [SVN repo URL] --no-metadata -A authors-transform.txt --stdlayout ~/temp

Convert svn:ignore properties to .gitignore :将 svn:ignore 属性转换为 .gitignore

cd ~/temp
git svn show-ignore > .gitignore
git add .gitignore
git commit -m 'Convert svn:ignore properties to .gitignore.'

Push repository to a bare git repository :将存储库推送到裸 git 存储库

git init --bare ~/new-bare.git
cd ~/new-bare.git
git symbolic-ref HEAD refs/heads/trunk

Then push the temp repository to the new bare repository.然后将临时存储库推送到新的裸存储库。

cd ~/temp
git remote add bare ~/new-bare.git
git config remote.bare.push 'refs/remotes/*:refs/heads/*'
git push bare

Rename “trunk” branch to “master” :将“trunk”分支重命名为“master”

cd ~/new-bare.git
git branch -m trunk master

Clean up branches and tags :清理分支和标签

cd ~/new-bare.git
git for-each-ref --format='%(refname)' refs/heads/tags |
cut -d / -f 4 |
while read ref
do
  git tag "$ref" "refs/heads/tags/$ref";
  git branch -D "tags/$ref";
done

Reference: http://john.albin.net/git/convert-subversion-to-git参考: http : //john.albin.net/git/convert-subversion-to-git

  1. All (?) svn -> git converters require live Subversion repository,所有 (?) svn -> git 转换器都需要实时的 Subversion 存储库,
  2. Tree-copy of repository is not a dump, it's usual file-level backup.存储库的树状副本不是转储,而是通常的文件级备份。

You have:你有:

  1. Install and configure any Subversion server (if your converter can't handle file:/// protocol for SVN, otherwise it's not needed - just unpack tarball(s) and check repo with svn client)安装和配置任何 Subversion 服务器(如果您的转换器无法处理 SVN 的file:///协议,否则不需要 - 只需解压 tarball 并使用 svn 客户端检查 repo)
  2. Read about git-svn阅读 git-svn
  3. Use git-svn使用 git-svn
  1. Take the dump file in your severs:在您的服务器中获取转储文件:

     svnadmin dump "repopath or url" > import.bkp git svn clone "back"
  2. Go to the clone path and then open git bash and run these commands:转到克隆路径,然后打开 git bash 并运行以下命令:

     git svn show-ignore > .gitignore git add .gitignore git commit -m "with message" git check in "git url"

reposurgeon工具支持将 SVN 转储文件直接(并且非常快速)转换为 Git 存储库。

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

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