如何使用git-svn和github跟踪上游SVN变化?
我使用git-svn将SVN repo转换为github上的git:
$ git svn clone -s http://svn.osqa.net/svnroot/osqa/ osqa
$ cd osqa
$ git remote add origin git@github.com:turian/osqa.git
$ git push origin master
然后我在我的git repo中进行了一些更改,提交并推送到github。
现在,我在一台新机器上。我想进行上游SVN更改,将它们与我的github repo合并,然后将它们推送到我的github repo。 This documentation说:“如果您丢失了本地副本,只需使用相同的设置再次运行导入,您将获得另一个包含所有必需SVN元信息的工作目录。”
所以我做了以下事情。但是没有一个命令按预期工作。如何使用git-svn和github跟踪上游SVN更改?我做错了什么?
$ git svn clone -s http://svn.osqa.net/svnroot/osqa/ osqa
$ cd osqa
$ git remote add origin git@github.com:turian/osqa.git
$ git push origin master
To git@github.com:turian/osqa.git
! [rejected] master -> master (non-fast forward)
error: failed to push some refs to 'git@github.com: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 git@github.com:turian/osqa
* [new branch] master -> origin/master
From git@github.com: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
答案 0 :(得分:5)
看起来,除了你的rebase之外,一切都按预期发生,但你可能会有更多的措辞。以下是我想在新机器上创建/集成位的方法:
--prefix=svn/
,以便我从Svn的所有远程分支都注释。git co -b local-branch svn/branchname
。现在你有一个很好的当地区域可供玩耍。git pull origin master
(从原点拉到主分支)。git svn rebase
。我没有试过这个,但这是一个非常典型的工作流程,你得到的错误似乎与你的两个遥控器(Svn和Github)的服务无关。它们看起来更通用,与您的工作流程以及您如何调用命令有关。