无法完成 Git Rebase
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22447429/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to finish a Git Rebase
提问by om39a
I am currently working on a branch and want to update it with master. So I tried doing a rebase.
我目前在一个分支上工作,想用 master 更新它。所以我试着做一个rebase。
current branch that I am workin on : crtdev
我正在工作的当前分支:crtdev
I tried doing rebase like,
我试过做 rebase 之类的,
git checkout crtdev
git rebase master
// used diff mergetool to solve merge issues
git rebase --continue
Now is says, Applying: "all commit messages that I have done in that branch"
现在说,应用:“我在该分支中完成的所有提交消息”
But after that what needs to be done?
但在那之后需要做什么?
I checked the repo and there are no changes and when I said git status
, I see merged files appearing with filename.html.orig
我检查了 repo 并且没有任何更改,当我说时git status
,我看到合并的文件与 filename.html.orig 一起出现
-- editWhen I run a git rebase --continue
I get this message No rebase in progress?
-- 编辑当我运行 a 时,git rebase --continue
我收到此消息No rebase in progress?
By running Git status
I see this message
通过运行Git status
我看到这条消息
# On branch crtdev
# Your branch and 'origin/crtdev' have diverged,
# and have 33 and 8 different commits each, respectively.
# (use "git pull" to merge the remote branch into yours)
To complete the rebase, what needs to be done?
要完成rebase,需要做什么?
回答by Jan Hudec
The rebase iscomplete.
底垫是完整的。
# On branch crtdev # Your branch and 'origin/crtdev' have diverged, # and have 33 and 8 different commits each, respectively. # (use "git pull" to merge the remote branch into yours)
# On branch crtdev # Your branch and 'origin/crtdev' have diverged, # and have 33 and 8 different commits each, respectively. # (use "git pull" to merge the remote branch into yours)
See, it does not say anything about rebase in progress. The rebase has finished. The only thing it says is that crtdev
and origin/crtdev
have diverged, but that's exactly what it is supposed to be saying after a rebase.
看,它没有说明正在进行的 rebase。rebase 已经完成。它说的唯一一件事就是,crtdev
并且origin/crtdev
已经发生分歧,但这正是它在重新设定基准后应该说的。
You have done rebase of crtdev
on master
. That means you've discarded the old history of crtdev
and re-created it on master
. However origin/crtdev
is a separate ref and still points to the old history. Your history now looks something like:
您已经完成了crtdev
on 的变基master
。这意味着您已经丢弃了 的旧历史crtdev
并在 上重新创建了它master
。然而origin/crtdev
是一个单独的参考,仍然指向旧的历史。你的历史现在看起来像:
X--Y--Z...--master
\ \
\ A'--B'--C'--D'--E'--F'--crtdev
\
A--B--C--D--E--F--origin/crtdev
The revisions A'
-crtdev
do the same changes (sans the conflict resolution) as the A
-origin/crtdev
did, but they are new changes. Because they also contain the new changes from master and commit ID in git is a checksum of it's content.
修订A'
-crtdev
做的同样的变化(没有冲突解决)A
-origin/crtdev
没有,但他们是新的变化。因为它们还包含来自 master 的新更改,git 中的提交 ID 是其内容的校验和。
Now if nobody else based anything on origin/crtdev
, you just want to push out the new history. git push -f
(branch names match, so arguments not needed; full command would begit push -f origin crtdev:crtdev
).
现在,如果没有其他人基于origin/crtdev
,您只想推出新的历史记录。git push -f
(分支名称匹配,因此不需要参数;完整的命令是git push -f origin crtdev:crtdev
)。
If, however, somebody already used origin/crtdev
, you've done the wrong thing. You should discard the results of the rebase (git reset --hard origin/crtdev
) and merge
instead. The problem is that if there is already other work based on the branch, it will remain to be based on it's old version. While it is possible to rebase it on the new version, it is very easy to forget and do something wrong and very confusing for the unsuspecting colleague.
但是,如果有人已经使用了origin/crtdev
,那么您就做错了。您应该丢弃 rebase ( git reset --hard origin/crtdev
)的结果,而merge
取而代之。问题是,如果已经有基于分支的其他工作,它将仍然基于它的旧版本。虽然可以在新版本上对其进行 rebase,但很容易忘记并做错事,并且让毫无戒心的同事感到非常困惑。