当引发一些冲突时,我们正在使用git rebase master
重新设置一个git分支。解决冲突后,我的同事(出于习惯)进行了git commit -am "commit msg"
而不是git add
操作。现在,git rebase无法继续。我该如何从中恢复?
$ git branch
* (no branch)
groups
groups_bkp
master
$ git rebase --continue
Applying: add and remove participants from group
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".
答案 0 :(得分:2)
事实证明这很简单,我所要做的就是软复位最后一次提交,就像我们removing the last commit from the current branch那样。 (请注意,此时HEAD指向(no branch)
)
$ git reset --soft HEAD~1
$ git status
# Not currently on any branch.
# You are currently rebasing.
# (all conflicts fixed: run "git rebase --continue")
#
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: layer.py
# modified: __init__.py
# modified: leave.py
# modified: add.py
# new file: add_success.py
# modified: remove.py
# new file: remove_success.py
#
$ git branch
* (no branch)
groups
master
之后,我添加了更改,并使用git rebase --continue
继续使用可以正常工作的rebase
$ git add .
$ git rebase --continue
Applying: add and remove participants from group
$ git branch
* groups
master
由于冲突数量众多,我们真的不想使用git rebase --abort
(我不确定它是否会在提交之后起作用)