2010-05-08 58 views
12

如何使用git-svn和github跟踪上游SVN更改?使用git-svn和github跟踪上游svn更改?

我以前的git-svn的转换一个SVN回购与git GitHub上:

$ git svn clone -s http://svn.osqa.net/svnroot/osqa/ osqa 
$ cd osqa 
$ git remote add origin [email protected]:turian/osqa.git 
$ git push origin master 

然后我改变了我的git回购,犯了一些变化,并推到github上。

现在,我在一台新机器上。我想采取上游SVN更改,将它们与我的github回购合并,并将它们推送到我的github回购。 This documentation说:“如果你失去了你的本地副本,只需再次使用相同的设置再次运行导入,你将得到所有必要的SVN元信息的另一个工作目录。”

所以我做了以下。但是没有一个命令按照需要工作。如何使用git-svn和github跟踪上游SVN更改?我究竟做错了什么?

$ git svn clone -s http://svn.osqa.net/svnroot/osqa/ osqa 
$ cd osqa 
$ git remote add origin [email protected]:turian/osqa.git 
$ git push origin master 
To [email protected]:turian/osqa.git 
! [rejected]  master -> master (non-fast forward) 
error: failed to push some refs to '[email protected]:turian/osqa.git' 
$ git pull 
remote: Counting objects: 21, done. 
remote: Compressing objects: 100% (17/17), done. 
remote: Total 17 (delta 7), reused 9 (delta 0) 
Unpacking objects: 100% (17/17), done. 
From [email protected]:turian/osqa 
* [new branch]  master  -> origin/master 
From [email protected]:turian/osqa 
* [new tag]   master  -> master 
You asked me to pull without telling me which branch you 
want to merge with, and 'branch.master.merge' in 
your configuration file does not tell me either. Please 
name which branch you want to merge on the command line and 
try again (e.g. 'git pull <repository> <refspec>'). 
See git-pull(1) for details on the refspec. 
... 
$ /usr//lib/git-core/git-svn rebase 
warning: refname 'master' is ambiguous. 
First, rewinding head to replay your work on top of it... 
Applying: Added forum/management/commands/dumpsettings.py 
error: Ref refs/heads/master is at 6acd747f95aef6d9bce37f86798a32c14e04b82e but expected a7109d94d813b20c230a029ecd67801e6067a452 
fatal: Cannot lock the ref 'refs/heads/master'. 
Could not move back to refs/heads/master 
rebase refs/remotes/trunk: command returned error: 1 

回答

5

它看起来像,除了你的rebase,一切都如预期发生,但有更多的你可能期望的言辞。以下是我想要在新机器上创建/集成位的方法:

  1. 克隆您的Svn存储库。理想情况下,我想从git回购开始,因为它是属于你自己的,并且处于已知状态,但我不知道有什么办法可以从Svn获取最初的内容,而不是将其克隆到其中。我喜欢在克隆时添加一个--prefix=svn/,这样我们所有的来自Svn的远程分支都会被注释。
  2. 添加您的出处(就像您所做的一样)。
  3. 创建一个本地分支进行工作。 git co -b local-branch svn/branchname。现在你有一个很好的当地玩东西的地方。
  4. 确保你在你刚创建的本地分支(你应该是)。
  5. 从Github拉。你已经做得正确,但含糊不清。要澄清含糊不清,请明确指出:git pull origin master(从原点分支到主分支)。
  6. 从Svn重新开始同步一切。 git svn rebase

我还没有试过这个,但它是一个非常典型的工作流程,你得到的错误似乎与你的两个远程服务(Svn和Github)没有关系。它们似乎更具通用性,与您的工作流程以及您如何调用命令有关。