git 正在变基。不能提交。如何继续或停止(中止)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29902967/
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
rebase in progress. Cannot commit. How to proceed or stop (abort)?
提问by Joseph Chambers
When I run:
当我运行时:
git status
I see this:
我看到这个:
rebase in progress; onto 9c168a5
You are currently rebasing branch 'master' on '9c168a5'.
(all conflicts fixed: run "git rebase --continue")
nothing to commit, working directory clean
When I do:
当我做:
ls `git rev-parse --git-dir` | grep rebase || echo no rebase
I see: rebase-apply
我看到:rebase-apply
I can't commit to origin.
我不能承诺起源。
git branch
Shows:
节目:
* (no branch, rebasing master)
develop
master
I'm stuck. I don't know what to do? Does it really take this long to rebase? git rebase --continue
doesn't do anything. I don't have anything in git status.. I'm just waiting for the rebase. What can I do?
我被困住了。我不知道该怎么办?rebase 真的需要这么长时间吗?git rebase --continue
什么都不做。我在 git status 中没有任何东西..我只是在等待变基。我能做什么?
UDATE: This is the output of: git rebase --continue
UDATE:这是输出: git rebase --continue
Applying: no message
No changes - did you forget to use 'git add'?
If there is nothing left to stage, chances are that something else
already introduced the same changes; you might want to skip this patch.
When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
git add . has nothing.
git 添加。什么都没有。
回答by Matthieu Moy
Rebase doesn't happen in the background. "rebase in progress" means that you started a rebase, and the rebase got interrupted because of conflict. You have to resume the rebase
(git rebase --continue
) or abort it (git rebase --abort
).
Rebase 不会在后台发生。“rebase in progress”意味着你开始了一个rebase,并且rebase由于冲突而中断。您必须恢复变基 ( git rebase --continue
) 或中止 ( git rebase --abort
)。
As the error message from git rebase --continue
suggests, you asked git to apply a patch that results in an empty patch. Most likely, this means the patch was already applied and you want to drop it using git rebase --skip
.
正如错误消息所git rebase --continue
暗示的那样,您要求 git 应用一个导致空补丁的补丁。很可能,这意味着补丁已经应用,您想使用git rebase --skip
.
回答by wildeyes
I got stuck in 'rebase status', I got
我陷入了“变基状态”,我得到了
On branch master
Your branch is up to date with 'origin/master'.
You are currently rebasing.
(all conflicts fixed: run "git rebase --continue")
nothing to commit, working tree clean
but running git rebase --skip
yielded error: could not read '.git/rebase-apply/head-name': No such file or directory
.
但运行git rebase --skip
屈服了error: could not read '.git/rebase-apply/head-name': No such file or directory
。
Running rm -fr ".git/rebase-apply"
helped.
跑步有rm -fr ".git/rebase-apply"
帮助。
Note: of course, do it only if you don't care about the rebase or if you're stuck on a previous rebase you don't want anymore.
注意:当然,只有在您不关心 rebase 或者如果您被困在您不再需要的先前 rebase 上时才执行此操作。
回答by Ani Menon
Step 1: Keep going
git rebase --continue
Step 2: fix CONFLICTS then
git add .
Back to step 1, now if it says
no changes ..
then rungit rebase --skip
then go back to step 1If you just want to quit rebase run
git rebase --abort
Once all changes are done run
git commit -m "rebase complete"
and you are done.
第一步:继续
git rebase --continue
第 2 步:然后修复 CONFLICTS
git add .
回到第 1 步,现在如果它说
no changes ..
然后运行,git rebase --skip
则返回第 1 步如果你只是想退出 rebase run
git rebase --abort
完成所有更改后,运行
git commit -m "rebase complete"
并完成。
回答by Schleis
You told your repository to rebase. It looks like you were on a commit (identified by SHA 9c168a5) and then did git rebase master
or git pull --rebase master
.
你告诉你的存储库变基。看起来您正在进行提交(由 SHA 9c168a5 标识),然后执行了git rebase master
或git pull --rebase master
.
You are rebasing the branch master onto that commit. You can end the rebase via git rebase --abort
. This would put back at the state that you were at before you started rebasing.
您正在将分支 master 重新设置为该提交。您可以通过git rebase --abort
. 这将使您回到开始变基之前的状态。
回答by jsears
I got into this state recently. After resolving conflicts during a rebase, I committed my changes, rather than running git rebase --continue
. This yields the same messages you saw when you ran your git status
and git rebase --continue
commands. I resolved the issue by running git rebase --abort
, and then re-running the rebase. One could likely also skip the rebase, but I wasn't sure what state that would leave me in.
我最近进入了这种状态。在变基期间解决冲突后,我提交了我的更改,而不是运行git rebase --continue
. 这会产生您在运行git status
和git rebase --continue
命令时看到的相同消息。我通过运行解决了这个问题git rebase --abort
,然后重新运行 rebase。人们可能也可以跳过 rebase,但我不确定这会让我处于什么状态。
$ git rebase --continue
Applying: <commit message>
No changes - did you forget to use 'git add'?
If there is nothing left to stage, chances are that something else
already introduced the same changes; you might want to skip this patch.
When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
$ git status
rebase in progress; onto 4df0775
You are currently rebasing branch '<local-branch-name>' on '4df0775'.
(all conflicts fixed: run "git rebase --continue")
nothing to commit, working directory clean
回答by Panda-313
If git rebase --abort
doesnt work and you still get
如果git rebase --abort
不起作用,你仍然得到
error: could not read '.git/rebase-apply/head-name': No such file or directory
错误:无法读取“.git/rebase-apply/head-name”:没有这样的文件或目录
Type:
类型:
git rebase --quit
回答by Alexis Wilke
I setup my git
to autorebaseon a git checkout
我安装我的git
给autorebase上git checkout
# in my ~/.gitconfig file
[branch]
autosetupmerge = always
autosetuprebase = always
Otherwise, it automatically merges when you switch between branches, which I think is the worst possible choice as the default.
否则,当你在分支之间切换时它会自动合并,我认为这是最糟糕的默认选择。
However, this has a side effect, when I switch to a branch and then git cherry-pick <commit-id>
I end up in this weirdstate every single time it has a conflict.
然而,这有一个副作用,当我切换到一个分支,然后每次发生冲突时我都会git cherry-pick <commit-id>
处于这种奇怪的状态。
I actually have to abort the rebase
, but first I fix the conflict, git add /path/to/file
the file (another very strange way to resolve the conflict in this case?!), then do a git commit -i /path/to/file
. Now I can abort the rebase
:
其实我有中止rebase
,但首先我解决冲突,git add /path/to/file
该文件(另一种解决这种情况?冲突很奇怪的方式),然后执行git commit -i /path/to/file
。现在我可以中止rebase
:
git checkout <other-branch>
git cherry-pick <commit-id>
...edit-conflict(s)...
git add path/to/file
git commit -i path/to/file
git rebase --abort
git commit .
git push --force origin <other-branch>
The second git commit .
seems to come from the abort. I'll fix my answer if I find out that I should abort the rebase
sooner.
第二个git commit .
似乎来自中止。如果我发现我应该尽早中止,我会修正我的答案rebase
。
The --force
on the push is required if you skip other commits and both branches are not smooth(both are missing commits from the other).
该--force
如果你跳过其他提交和两个分支不上推,需要平滑(两者都缺少来自其他提交)。
回答by Prabs
回答by Kevin Aung
Mine was an error that popped up from BitBucket. Ran git am --skip
fixed it.
我的是一个从 BitBucket 弹出的错误。冉git am --skip
修好了。