【转载】Synchronising SVN and Git

【转载】 原文地址: Synchronising SVN and Git | jevon.org

SVN / Git

  1. Re-establishing a git svn clone on a separate machine

I wanted to clone my existing SVN repository, https://code.google.com/p/svntime/, into a new Git repository https://github.com/soundasleep/svntime.

Based on Using Git with Subversion and Importing from Subversion.

Note that this means that all revisions and issues will all appear to come from the same user. Setting up SVN/Git synchronisation to support multiple users with correct authentication requires a lot of extra architecture and work and security for storing passwords.

0. Create a map of SVN authors to Git authors

This will let Github blame your commits properly with the -A flag. For example svn-authors.txt:

soundasleep@gmail.com = Jevon Wright <jevon@jevon.org>
soundasleep = Jevon Wright <jevon@jevon.org>
(no author) = Google Code <code@google.com>

1. Clone remote SVN into local Git

  1. Execute git svn clone -s https://svntime.googlecode.com/svn/ svntime -A svn-authors.txt --prefix=origin/ (NOT the /trunk dir! The -s flag assumes /trunk.)

You can also do subdirectories within the repository for subprojects without the -s flag, e.g. git svn clone https://svntime.googlecode.com/svn/trunk/sub-project/ sub-project -A svn-authors.txt.

2. Push local Git into remote Git

  1. Create a new empty Git repository on Github
  2. Add the remote origin source: git remote add origin https://github.com/soundasleep/svntime.git
  3. Push the SVN commits to Git: git push origin master

This will create individual commits for each SVN revision.

3. Make a local change, commit to both Git and SVN

  1. Modify a file.
  2. Commit it to local Git: git add -A && git commit
  3. Push it to remote Git: git push
  4. Commit it to remote SVN: git svn dcommit
  5. Setup the remote Git as the remote origin: git branch --set-upstream-to=origin/master master

4. Merge remote SVN changes into local Git

  1. Update the local Git from remote SVN: git svn rebase -A ../svn-authors.txt (each revision will appear as a new commit)
  2. Push to remote Git: git push

5. Merge remote Git changes into SVN

  1. Pull from remote Git into local Git: git pull
  2. Update the local Git from remote SVN: git svn rebase -A ../svn-authors.txt
  3. Commit changes to remote SVN: git svn dcommit (each commit will appear as a new revision)

‎如果您正确设置了作者地图列表,则您的 Github 将正确识别旧提交。‎

6. Merge a Pull Request

  1. For example, https://github.com/soundasleep/openclerk/pull/1
  2. Follow the Github command line instructions to checkout the pull request branch as a separate remote branch
  3. Execute git rebase to rebase this branch to the latest master - you’ll probably have to git mergetool a lot, since the branch will have no knowledge of master’s commits
  4. git push and git svn dcommit as usual

Unable to extract revision information from commit

If you get this during a git svn dcommit, then you’ve probably messed up the merge somewhere - you need to git rebase before you merge changes between branches.

git svn rebase: Unknown option: strategy-option

Good luck. I think this is a bug.

ignore-paths not matching files

It turns out the regexp accepted by --ignore-paths is not a complete regexp; it needs an anchor (^ or $) in order to match. So instead of doing something like --ignore-paths=".+custom.css", you need to do --ignore-paths="custom.css$".

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值