Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git rebase --continue without opening the editor

Tags:

git

When invoking git rebase --continue after a normal rebase conflict, the editor (GIT_EDITOR) opens and asks for modifying the commit message. Because commit messages may contain leading # this might fail.

$ export GIT_EDITOR=true
$ git rebase --continue
Aborting commit due to empty commit message.
error: could not commit staged changes.

In the Git rebase documentation there is following paragraph

Commit Rewording When a conflict occurs while rebasing, rebase stops and asks the user to resolve. Since the user may need to make notable changes while resolving conflicts, after conflicts are resolved and the user has run git rebase --continue, the rebase should open an editor and ask the user to update the commit message. The merge backend does this, while the apply backend blindly applies the original commit message.

So I tried to switch to the apply backend, but it still fails:

$ export GIT_EDITOR=true
$ git config rebase.backend apply
$ $ git config --list | grep backend
rebase.backend=apply
$ git rebase --continue
Aborting commit due to empty commit message.
error: could not commit staged changes.

How to force Git to blindly apply the commit message?

like image 258
Thomas S. Avatar asked Oct 09 '20 08:10

Thomas S.


People also ask

How do you do rebase continue?

When you're finished making all your changes, you can run git rebase --continue . As before, Git is showing the commit message for you to edit. You can change the text ( "i cant' typ goods" ), save the file, and close the editor. Git will finish the rebase and return you to the terminal.

How do I continue rebase after a conflict?

To fix the conflict, you can follow the standard procedures for resolving merge conflicts from the command line. When you're finished, you'll need to call git rebase --continue in order for Git to continue processing the rest of the rebase.

What does git rebase -- skip do?

Git will return you to your branch's state as it was before git rebase was called. You can run git rebase --skip to completely skip the commit. That means that none of the changes introduced by the problematic commit will be included. It is very rare that you would choose this option.


1 Answers

A workaround I've found, is specifying the core.commentChar detected from the .git/rebase-merge/message (here @):

git -c core.commentChar=@ rebase --continue
like image 60
Thomas S. Avatar answered Sep 28 '22 21:09

Thomas S.