I have a branch with ~50 commits pushed to origin. Then one day, I'd like to edit the text of the commit messages (because we are using a reference to Jira task in the commit message, and I need to fix it). So the only way I know is to run an interactive rebase:
git rebase -i origin/my-precious-branch~30 my-precious-branch
and then I select a few commits and change pick to r (for reword). And what happens next is what puzzles me. For most of the commits - it simply opens the editor where I can manually alter the commit text (fine).
But then it stops for one of them:
error: could not apply 616b308fe9e... OLD-MESSAGE: 1
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".
Could not apply 616b308fe9e3d4cd8845d090720f1cdad97add73... OLD-MESSAGE: 1
What is happening here? And why?
Based on your comments, it looks like you have one or more merge commits which your rebase is hitting. Rebasing a merge commit gets complicated, because you either have to redo the merge, or possibly let Git try to recreate the merge. In any case, the conflict you are encountering is likely due to that it is a merge commit.
See here for how to handle this situation:
Rebasing a Git merge commit
If you are prepared for such conflicts, then you may still reword the commit comments.
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