`

git-svn使用方式及使用中的问题(已解决)

 
阅读更多
之前的项目都是使用SVN,今天在git-svn上工作时,出了一点问题,记录一下,以便将来查询。
使用过程:
1、从svn clone出项目,加上-s参数以标记识别svn标准的目录分支结构,同时通过show-ignore设置git库的exclude属性:
Java代码 复制代码
  1. gitsvnclone-shttps://svn.xxx.com/svn/xxx
  2. gitsvnshow-ignore>>.git/info/exclude


2、建立本地工作分支,开始工作:
Java代码 复制代码
  1. gitcheckout-bwork

修改内容直接commit,加上-a开头以省略git add操作:
Java代码 复制代码
  1. gitcommit-a


3、提交回svn的过程:
Java代码 复制代码
  1. gitcheckoutmaster
  2. gitmergework
  3. gitsvnrebase
  4. gitsvndcommit


在今天工作中,我提交回svn的方式是:
Java代码 复制代码
  1. gitcheckoutmaster
  2. gitsvnrebase
  3. gitmergework

结果svn rebase时在master分支上产生了一个新的node,这样merge时就不能快速合并,出现了冲突,修复后,在dcommit时出错,出现N个孤立节点。因为不熟悉,就checkout出work分支,进行了dcommit,然后重新生成一次git库。

(7/14更新)

今天解决了这个问题,参考以下网址:https://wiki.bnl.gov/dayabay/index.php?title=Synchronizing_Repositories
以下重新描述一下问题和解决方法:
1、在执行git svn dcommit时,出现如下错误:
Committing to https://svn.xxx.com/svn/projects/trunk ...
提交时发生合并冲突: 您的文件或目录”test/functional/xxx_controller_test.rb“可能已经过时: The version resource does not correspond to the resource within the transaction. Either the requested version resource is out of date (needs to be updated), or the requested version resource is newer than the transaction root (restart the commit). at /usr/bin/git-svn line 450

2、这时,重新执行以下步骤即可:
Java代码 复制代码
  1. gitsvnfetch
  2. gitsvnrebase
  3. gitsvndcommit

但我在执行git svn rebase时,又出现冲突,这个时候,只需要手工合并掉冲突,并重新add一下:
Java代码 复制代码
  1. gitadd.

然后,再执行:
Java代码 复制代码
  1. gitrebase--continue

如果报告说没有修改内容,则换成执行:
Java代码 复制代码
  1. gitrebase--skip

完成rebase过程,这时就可以git svn dcommit了。

这样,总算解决了svn历史冲突问题,不用象前面那样笨笨的重新git-svn clone.
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics