git-svn使用方式及使用中的问题

来源:互联网 发布:手机连接电视同一网络 编辑:程序博客网 时间:2024/06/07 16:44
之前的项目都是使用SVN,今天在git-svn上工作时,出了一点问题,记录一下,以便将来查询。 
使用过程: 
1、从svn clone出项目,加上-s参数以标记识别svn标准的目录分支结构,同时通过show-ignore设置git库的exclude属性: 
Java代码  收藏代码
  1. git svn clone -s https://svn.xxx.com/svn/xxx  
  2. git svn show-ignore >> .git/info/exclude  


2、建立本地工作分支,开始工作: 
Java代码  收藏代码
  1. git checkout -b work  

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


3、提交回svn的过程: 
Java代码  收藏代码
  1. git checkout master  
  2. git merge work  
  3. git svn rebase  
  4. git svn dcommit  


在今天工作中,我提交回svn的方式是: 
Java代码  收藏代码
  1. git checkout master  
  2. git svn rebase  
  3. git merge work  

结果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. git svn fetch  
  2. git svn rebase  
  3. git svn dcommit  

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

然后,再执行: 
Java代码  收藏代码
  1. git rebase --continue  

如果报告说没有修改内容,则换成执行: 
Java代码  收藏代码
  1. git rebase --skip  

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