Migration from SVN to Git

Prepare authors mapping file

The migration includs the commit history from svn, so we need an account mapping file between svn and github accounts. Here's the sample content of mapping file:

ts32145 = James Lu <james.lu@example.com>
cm56426 = Catalin Mike <catalin.mike@example.com>

The svn account should be set on the left and the github account should be set on the right with the email.

Please notice that all the authors of this svn project should be included in this mapping file, or the migration will not proceed successfully.

If some of the authors don’t have any github account created, you should also provide this formatted file. The only difference is if the github account exists, the account name in the commit history dashboard of github is linkable to its own profile page, or it’s plain text.

Here are 2 approaches to get the authors list from svn:

Eclipse SVN Plugin

Open svn repository history -> Right click anywhere in the history tab, then click Quick Filter -> Check Author then you can see the authors list

svn command

The following svn command of svn could also be executed to get the authors list if you get the svn client installed.

svn log -q file:///path/to/subversion/project | grep -e '^r' | awk 'BEGIN { FS = "|" } ; { print $2 }' | sort | uniq
Migrate Trunk & Branch
  • Create git repository

mkdir ses && cd ses
mkdir trunk && cd trunk
  • Init git repository

git init
git svn init https://path/to/svn/project
  • Paste the authors.txt to the repository root path and config account
    mapping file:

git config svn.authorsfile authors.txt
  • Fetch code

git svn fetch
  • Add remote and push code to git

git remote add origin ssh://path/to/git/repository.git
git push origin master
Migrate Tags

Git uses two main types of tags: lightweight and annotated. A lightweight tag is very much like a branch that doesn’t change – it’s just a pointer to a specific commit.

Annotated tags, however, are stored as full objects in the Git database. They’re checksummed; contain the tagger name, email, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG). It’s generally recommended that you create annotated tags so you can have all this information; but if you want a temporary tag or for some reason don’t want to keep the other information, lightweight tags are available too.

Annnotated tag
  • Create tag v1.0

git tag –a v1.0 –m “first tag”
  • Review tags

git tag
  • Push tag to remote

push origin v1.0
Lightweight tag
  • Create tag v1.0-lw

git tag v1.0-lw
  • Review tags

git tag
  • Push tag to remote

git push origin v1.0-lw
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值