git-svn rebase 和 dcommit 问题

8
git version 1.7.1
svn, version 1.6.12
Ubuntu 10.10

我之前使用过git和svn,但从未将它们结合使用过。我有一个git仓库,需要将其转移到subversion仓库中。因此,我一直在使用git-svn。大部分时间都能正常工作,但是我发现自己陷入了一个死循环。

这个项目只有我在开发。

我对我的分支进行了一些更改,然后将它们暂存:

git stage gateway.c

然后在本地将它们提交到git:
git commit m"Made some changes"

然后我想将它们提交到Subversion。获取最新更新:

git svn rebase

然后我收到以下消息:
It seems that I cannot create a rebase-apply directory, and
I wonder if you are in the middle of patch application or another
rebase.  If that is not the case, please
        rm -fr /home/joe/projects/gateway/.git/rebase-apply
and run me again.  I am stopping in case you still have something
valuable there.
rebase refs/remotes/trunk: command returned error: 1

I then doing the following:
rm -fr /home/joe/projects/gateway/.git/rebase-apply

然后我再次进行变基:

git svn rebase

这是需要翻译的内容:

信息如下:

First, rewinding head to replay your work on top of it...
Applying: Issue with getting the port from the user context.
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging driver.c
Auto-merging gateway.c
CONFLICT (content): Merge conflict in gateway.c
Failed to merge in the changes.
Patch failed at 0001 Issue with getting the port from the user context.

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".

rebase refs/remotes/trunk: command returned error: 1

这让我进入了一个叫做“branch”的分支,这个分支是什么,有什么用途?
*(no branch)

我解决了那个分支的冲突。然后我切换到我的play_video分支。我尝试做另一个:

svn git dcommit

我又开始打圆场了。

在我把头拔光之前,有人能给我提供一些建议吗?

非常感谢任何建议。


我这里也有同样的问题......将近三年了,没有任何建议...... - Quartz
4个回答

3

虽然不是完整的答案,但可以确定的是:

*(no branch)

这意味着你会进入一个 DETACHED HEAD 模式,你可以在 git svn 上下文中看到,在 "Can I recover lost commits in a SVN repository using a local tracking git-svn branch?" 中有相关内容。
还可以参考 "Why did git detach my head?"。

所以请确保:

  • 在每个步骤中,你不是处于分离的 HEAD (没有分支)。
  • 你要将一个存在于 SVN 仓库中的分支 dcommit(而不是一个纯本地 Git 分支)。

我发现自己陷入了困境,尝试了许多不同的git命令,但最终在能够进行任何进一步的svn合并之前,我运行了git svn dcommit。 - hellatan
@dtan:你有需要帮助的问题或错误信息吗? - VonC
@VonC - 不,我很久以前就遇到了这个问题,最近又遇到了。我只知道尝试解密正在发生的事情并不好玩,但现在我至少知道下次再遇到这个问题该怎么做了。谢谢。 - hellatan
这个答案是不正确的,任何时候如果你有一个不完整的rebase(无论是svn还是其他),你都会处于分离的head状态。我也遇到了git合并和随后的'git svn rebase'问题。 - Quartz

1
你是否使用了谷歌的指南在这里将你的Git存储库导入到svn中? 在使用这些指令后我遇到了类似的错误:最初的导入很好,但是在某个地方出了问题,我无法推送后续的提交。
我通过使用git svn init创建一个全新的git存储库来跟踪我的svn存储库并解决了这个问题。

1
我遇到了类似的问题,可能是因为在推送到 SVN 远程之前先推送到了 Git 远程,从而搞乱了我的 Git 历史记录。每次尝试向 SVN 提交内容时,似乎 Git 都会尝试重放我以前的所有提交,即使它们已经存在于 SVN 中,所以我只需运行 git rebase --skip 直到回到最新的提交,但最简单的解决方案可能是克隆一个全新的 Git SVN。

再多思考了两秒钟,我意识到每次在将代码推送到svn之后,我都从远程git拉取,这导致了错误的git历史记录被再次拉下来。我进行了一次强制推送到git远程仓库,彻底解决了历史记录不一致的问题,现在rebase问题已经消失了。 - Kevin Dubois

1

解决完冲突后,需要在运行git svn dcommit之前运行git rebase --continue


git rebase --continue 只是说没有要提交的内容。 - Quartz

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接