问题
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
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?
UDATE: This is the output of: 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.
回答1:
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
).
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
.
回答2:
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
.
Running rm -fr ".git/rebase-apply"
helped.
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.
回答3:
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
.
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.
回答4:
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
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
回答5:
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.
回答6:
I setup my git
to autorebase on a 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 weird state every single time it has a conflict.
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
:
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.
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).
回答7:
Another option to ABORT / SKIP / CONTINUE from IDE
VCS > Git > Abort Rebasing
回答8:
Mine was an error that popped up from BitBucket. Ran git am --skip
fixed it.
来源:https://stackoverflow.com/questions/29902967/rebase-in-progress-cannot-commit-how-to-proceed-or-stop-abort