We were rebasing a git branch, using git rebase master
, when some conflicts were thrown. After resolving the conflicts, my coworker (out of habit) did a git commit -am "commit msg"
instead of a git add
operation. Now, git rebase can not continue. How do I recover from this?
$ 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".
This turned out to be pretty simple, all I had to do was to soft reset the last commit, just like we would if we were removing the last commit from the current branch . (Note that the HEAD points to (no branch)
at the moment)
$ 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
After that, I added the changes and continued with the rebase using git rebase --continue
which worked all right
$ git add .
$ git rebase --continue
Applying: add and remove participants from group
$ git branch
* groups
master
Since the conflicts were in large number, we really didn't want to use git rebase --abort
(and I'm not sure if it would have worked either, after that commit)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.