SVN迁移到Git [英] SVN to Git migration

查看:282
本文介绍了SVN迁移到Git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过下载 svn2git.sh 脚本文件并使用以下命令从Windows上的SVN迁移到git。

  sh svn2git.sh [ProjectName] [SVN Repo link] [SVN Rev(Probably 0)] [Stash Repo Link] 

我对此很陌生,在git-svn和svn2git用法之间非常混淆。任何人都可以使用 svn2git 工具向我建议svn迁移git的步骤?

解决方案

我为svn创建了一个脚本来迁移git。这个脚本将svn repo迁移到git以及它的所有标记和历史记录。

先决条件:
确保在您的计算机上安装GIT和SVN,然后再继续进行迁移。



使用的变量描述



SVN_REPO_LINK:http链接到svn repo托管的位置



GIT_REPO_NAME:您想要给您的名称新的git repo



GIT_REPO_LINK:链接到您的git服务器您想要承载回购的地方。
[它基本上是一个你想添加的GIT远程控制器]

作者文件:
在svn中,提交仅与用户名关联,但除了用户名之外,还需要git存储库电子邮件地址。为了维护git中的svn提交,需要用户电子邮件。这个文件是为了这个目的。
文件格式如下:

  svn用户名= Name< email> 

Helen_david = Helen David< helen.david@mycompany.com>

RobinR =罗宾·罗斯

脚本

  git svn clone --stdlayout --prefix'svn /'-A authors.txt $ SVN_REPO_LINK $ GIT_REPO_NAME 
cd $ GIT_REPO_NAME

git for -each-ref refs / remotes / svn --format =%(refname:short)| sed的#svn / ##'| grep -v'^ tags'|同时阅读分文;做git分支$ aBranch svn / $ aBranch; done
git branch -d trunk
git for-each-ref refs / remotes / svn / tags --format =%(refname:short)| sed的#svn / tags / ##'|同时阅读标签;做git标签$ aTag svn / tags / $ aTag;完成
git remote add origin $ GIT_REPO_LINK
git push -u - 全部起源
git push - 标签来源

现在您的资料库会随其所有标签,分支和历史一起迁移。


I am trying to migrate from SVN to git on windows by downloading the svn2git.sh script file and using the following command.

sh svn2git.sh [ProjectName] [SVN Repo link] [SVN Rev (Probably 0)] [Stash Repo Link]

I am new to this and very confused between git-svn and svn2git usage. Can anyone suggest me the steps for svn to git migration using svn2git tool?

解决方案

I created a script for svn to git migration. This script migrates the svn repo to git along with all it's tags and history maintained.

Pre-requisites : Make sure GIT and SVN are installed on your machine before moving ahead with the migration.

Description for Variables used

SVN_REPO_LINK : http link to where you svn repo is hosted

GIT_REPO_NAME : the name that you want to give to you new git repo

GIT_REPO_LINK : link to your git server where you want to host the repo. [It is basically a GIT remote that you would want to add]

Authors File : In svn the commits are associated with the username only, but in git repository email address is also required besides the username. Inorder to maintain the svn commits in git, user emails are are needed. This file serves that purpose. The format of the file is as follows :

svn user name = Name <email>

Helen_david = Helen David <helen.david@mycompany.com>

RobinR = Robin Rose <robin.rose@mycompany.com>

Script

git svn clone --stdlayout --prefix 'svn/' -A authors.txt $SVN_REPO_LINK $GIT_REPO_NAME
cd $GIT_REPO_NAME

git for-each-ref refs/remotes/svn --format="%(refname:short)" | sed 's#svn/##' | grep -v '^tags'| while read aBranch; do git branch $aBranch svn/$aBranch; done
git branch -d trunk 
git for-each-ref refs/remotes/svn/tags --format="%(refname:short)" | sed 's#svn/tags/##' | while read aTag; do git tag $aTag svn/tags/$aTag; done
git remote add origin $GIT_REPO_LINK
git push -u --all origin
git push --tags origin

Now your repository is migrated along with all it's tags,branches and history.

这篇关于SVN迁移到Git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆