私信  •  关注

community wiki 3 revs Pablo Be

community wiki 3 revs Pablo Be 最近创建的主题
community wiki 3 revs Pablo Be 最近回复了
9 年前
回复了 community wiki 3 revs Pablo Be 创建的主题 » 如何将具有历史记录的SVN存储库迁移到新的Git存储库?

我贴了一个循序渐进的指南( here )将svn转换为git,包括将svn标记转换为git标记,将svn分支转换为git分支。

短版:

1)从特定版本号克隆SVN。(修订号必须是要迁移的最旧版本)

git svn clone --username=yourSvnUsername -T trunk_subdir -t tags_subdir -b branches_subdir -r aRevisionNumber svn_url gitreponame

2)获取SVN数据。这是最需要时间的一步。

cd gitreponame
git svn fetch

重复git svn fetch,直到无错误完成

3)更新主分支

git svn rebase

4)通过复制引用从SVN分支创建本地分支

cp .git/refs/remotes/origin/* .git/refs/heads/

5)将svn标签转换成git标签

git for-each-ref refs/remotes/origin/tags | sed 's#^.*\([[:xdigit:]]\{40\}\).*refs/remotes/origin/tags/\(.*\)$#\2 \1#g' | while read p; do git tag -m "tag from svn" $p; done

6)将存储库放在更好的地方,如Github

git remotes add newrepo git@github.com:aUser/aProjectName.git
git push newrepo refs/heads/*
git push --tags newrepo

如果你想了解更多细节,请阅读我的 post 或者问我。