Search code examples
gitgit-rebasegit-configgit-interactive-rebase

Silence git rebase --interactive's "how to proceed" message


I've written a script to automate a git rebase --interactive to edit a specified commit using GIT_SEQUENCE_EDITOR=sed ...s/pick/edit/...

How do I prevent the "helpful" message that git rebase --interactive prints out:

Stopped at 307c446...  Add candy-text
You can amend the commit now, with

  git commit --amend 

Once you are satisfied with your changes, run

  git rebase --continue

This message is printed to STDERR, and I still want to see any errors of the rebase command itself and/or any {pre,post}-rebase hooks, so 2>/dev/null isn't an option.

From the git config documentation, I've tried:

git -c advice.statusHints=false rebase --quiet --interactive --autostash --autosquash "$commit"~

I've also tried disabling advice.resolveConflict and advise.detachedHead.

There don't seem to be any useful options under rebase.*.


Solution

  • Both git-rebase--preserve-merges.sh (which calls warn ()) and the sequencer.c don't offer any option to prevent the display of that warning.

    You can modify git-rebase--preserve-merges.sh locally, but that won't be portable (plus git rebase is being rewritten in C anyway, starting with Git 2.19)

    Or you can submit a patch with a new setting allowing to silence that warning.


    Or, as kostix suggests in the comments, you need to process the output of your command to filter out what you don't need:

    your best bet may be to match it exactly by your hook script and wipe out.
    Possibly do this in two steps:

    1. match ^Stopped at [[:xdigit:]]+.*$ and remove it if matched;
    2. if matched and removed, match the whole following banner and remove, if matched.

    (although kostix suggests to do this with a more advanced language than bash)