I came across the following problem:
During git rebase one of automatically resolved commits has an error, i.e. as a result of automatic resolution, a function declaration was introduced for the second time in the header file and compilation fails.
My question is: is it possible to go back to that automatically resolved commit, resolve it manually and then continue with the rebase, assuming that I am still within the rebase process?
You should first finish the original rebase, so that you are in a known state with your repository. Then it is quite easy to edit the commit that introduced the error with interactive rebase. Check out the sha1 of the commit you want to fix, then do
git rebase -i <sha1>^
An editor will open containing commits from the HEAD up to the commit you want to fix. Find the commit from the list (it should be the first one), replace the word "pick" with "edit", save and exit editor.
Now you can fix the bug, then do
git commit -a --amend
git rebase --continue
That's it!
Although a rebase within a rebase will not work, it is possible to git commit --amend
to the last committed modification.
If the problem is caused by the commit just before the current one being rebased (i.e its the last one committed), you can modify it without any side effects to the rebase process.
So when I got into this situation, I did the following:
Unstage the current manual modification being rebased:
$ git reset HEAD <files being rebased>
Stage my fix for the last commit causing the problem:
$ git add <files with compilation fix>
Add the compilation fix into the last committed modification:
$ git commit --amend
Return to the current manual modification being rebased:
$ git add <files being rebased>
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With