将本地 svn repo 转储转换为 git

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16005193/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 08:25:45  来源:igfitidea点击:

Converting a local svn repo dump to git

gitsvnversion-controlsvn2git

提问by R.. GitHub STOP HELPING ICE

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. They're tarballs of the original repository structure on the server. What I want to do is convert them to git repositories as a basis for future work/reviving the projects. 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. Do I need to install and setup and SVN server to do this conversion, or is there some way I can point either git cloneor svn2git(or another tool) at the repo dump I have?

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

回答by Asenar

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

回答by Amir Saniyan

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

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

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

回答by Lazy Badger

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

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)
  2. Read about git-svn
  3. Use git-svn
  1. 安装和配置任何 Subversion 服务器(如果您的转换器无法处理file:///SVN 协议,否则不需要 - 只需解压缩 tarball(s)并使用 svn 客户端检查 repo)
  2. 阅读 git-svn
  3. 使用 git-svn

回答by sreekanth golla

  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 svn show-ignore > .gitignore
    
    git add .gitignore
    
    git commit -m "with message"
    
    git check in "git url"
    
  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"