繁体   English   中英

将本地 svn repo 转储转换为 git

[英]Converting a local svn repo dump to git

我搜索了相关问题,但找不到与我的具体情况相符的任何内容:我有一些来自多年前被关闭的 SVN 服务器的旧存储库档案。 它们是服务器上原始存储库结构的 tarball。 我想做的是将它们转换为 git 存储库,作为未来工作/恢复项目的基础。 我已经阅读了几个关于转换过程的教程,我想我可以弄清楚作者转换、分支映射等,但它们都假设您有一个 SVN 服务器和一个存储库的 url。 我是否需要安装和设置和 SVN 服务器来执行此转换,或者有什么方法可以将git clonesvn2git (或其他工具)指向我拥有的 repo 转储?

在本地安装 subversion 以导入您的转储,然后使用 git-svn 包。

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

检索所有 Subversion 提交者的列表

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

使用 git-svn 克隆 Subversion 存储库

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

将 svn:ignore 属性转换为 .gitignore

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

将存储库推送到裸 git 存储库

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

然后将临时存储库推送到新的裸存储库。

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

将“trunk”分支重命名为“master”

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

清理分支和标签

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

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

  1. 所有 (?) svn -> git 转换器都需要实时的 Subversion 存储库,
  2. 存储库的树状副本不是转储,而是通常的文件级备份。

你有:

  1. 安装和配置任何 Subversion 服务器(如果您的转换器无法处理 SVN 的file:///协议,否则不需要 - 只需解压 tarball 并使用 svn 客户端检查 repo)
  2. 阅读 git-svn
  3. 使用 git-svn
  1. 在您的服务器中获取转储文件:

     svnadmin dump "repopath or url" > import.bkp git svn clone "back"
  2. 转到克隆路径,然后打开 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