简体   繁体   English

使用git-svn和github跟踪上游svn的变化?

[英]Tracking upstream svn changes with git-svn and github?

How do I track upstream SVN changes using git-svn and github? 如何使用git-svn和github跟踪上游SVN更改?

I used git-svn to convert an SVN repo to git on github: 我使用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

I then made a few changes in my git repo, committed, and pushed to github. 然后我在我的git repo中进行了一些更改,提交并推送到github。

Now, I am on a new machine. 现在,我在一台新机器上。 I want to take upstream SVN changes, merge them with my github repo, and push them to my github repo. 我想进行上游SVN更改,将它们与我的github repo合并,然后将它们推送到我的github repo。 This documentation says: "If you ever lose your local copy, just run the import again with the same settings, and you'll get another working directory with all the necessary SVN metainfo." 该文档说:“如果您丢失了本地副本,只需使用相同的设置再次运行导入,您将获得另一个包含所有必需SVN元信息的工作目录。”

So I did the following. 所以我做了以下几点。 But none of the commands work as desired. 但是没有一个命令按预期工作。 How do I track upstream SVN changes using git-svn and github? 如何使用git-svn和github跟踪上游SVN更改? What am I doing wrong? 我究竟做错了什么?

$ 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

It looks like, with the exception of your rebase, everything happened as expected, but with a lot more verbiage that you might expect. 看起来,除了你的rebase之外,一切都按预期发生,但你可能会有更多的措辞。 Here's what I think I would do to create/integrate the bits on a new machine: 以下是我想在新机器上创建/集成位的方法:

  1. Clone your Svn repository. 克隆您的Svn存储库。 Ideally, I'd like to start with the git repo because it's yours and it's in a known state, but I don't know of any way to initially pull content from Svn than to clone it. 理想情况下,我想从git repo开始,因为它是你的,并且它处于已知状态,但我不知道有什么办法从Svn 最初提取内容而不是克隆它。 I like to add a --prefix=svn/ when cloning so that all of my remote branches from Svn are annotated as such. 我喜欢在克隆时添加--prefix=svn/ ,这样我从Svn的所有远程分支都会被注释。
  2. Add your origin (just like you've done). 添加您的来源(就像您已经完成的那样)。
  3. Create a local branch for working. 创建一个本地分支进行工作。 git co -b local-branch svn/branchname . git co -b local-branch svn/branchname Now you have a nice, local area for playing with stuff. 现在你有一个很好的本地区域可供玩耍。
  4. Ensure that you're on that local branch you just created (you should be). 确保您在刚刚创建的本地分支上(您应该)。
  5. Pull from Github. 从Github拉。 You've done this correctly, but ambiguously. 你已经正确地完成了这个,但含糊不清。 To clear up the ambiguity, be explicit: git pull origin master (pull from origin to the master branch). 为了消除歧义,请明确: git pull origin master (从原点拉到master分支)。
  6. Rebase from Svn to sync everything up. 从Svn重新启动以同步所有内容。 git svn rebase . git svn rebase

I haven't tried this, but it's a pretty typical workflow and the errors you're getting don't seem to be related to your service of two remotes (Svn and Github). 我没有试过这个,但这是一个非常典型的工作流程,你得到的错误似乎与你的两个遥控器(Svn和Github)的服务无关。 They appear to be a bit more generic and related to your workflow and how you're calling the commands. 它们看起来更通用,与您的工作流程以及您如何调用命令有关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM