To add OP yankee's excellent answer , Git git rebase --interactive --exec provide a more reliable git rebase --interactive --exec , especially in the event of a failed execution.
In fact, see the new --reschedule-failed-exec from Git 2.21 in the last part of this answer.
See commit b12d3e9 [May 22, 2015], and commit 1d968ca [May 22, 2015] by Mathieu Moy ( moy ) .
(Combined Junio C Hamano - gitster - in commit a6be52e , June 01, 2015)
The ' exec ' command sends the current commit to stopped-sha , which should contain the original commit (before rebasing).
As a result, if the ' exec ' command fails, the next ' git rebase --continue ' will send the current commit as a trap after overwriting.
Full documentation:
rebase -i : fixed rebase -i post-rewrite unsuccessful exec command
Usually, when " git rebase " stops before rebasing is complete, this gives the user the ability to edit the commit (for example, using the " edit " command).
In such cases, git rebase leaves the rewritable sha1 commit at "$state_dir"/stopped-sha , and the subsequent git rebase --continue calls this post-rewrite hook with this sha1 as <old-sha1> argument to post-rewrite hook.
The case of stopping " git rebase " due to the unsuccessful " exec " command is different: it gives the user the opportunity to examine or correct the error, but does not stop saying "here commit for editing, use --continue when everything is ready . "
Thus, there is no reason to call the post-rewrite hook on exec commands.
If the user rewrote the commit, that would be with ' git commit --amend ', which already called the post-rewrite hook.
Correct the behavior to:
- do not leave the
stopped-sha file if the exec command fails , - and teach
git rebase --continue skip record_in_rewritten if no git rebase --continue stopped-sha file is found.
To simplify the management of erroneous exec directives related to relocation, Git 2.21 (Q1 2019) introduces --reschedule-failed-exec with " git rebase -i ", which learned to re-execute the command given by " exec " to run after how it failed the last time.
See commit 81ef8ee , commit 969de3f , commit d421afa (December 10, 2018) Johannes dscho ( dscho ) .
(Combined Junio C Hamano - gitster - in commit d9d9ab0 , January 29, 2019)
rebase : type --reschedule-failed-exec
--exec option to use the --exec option - check that each commit in the topic branch is compiled correctly using git rebase -x make <base> .
However, when exec fails in such a rebase, it is not rescheduled, which is not particularly useful in this case.
Let me suggest a flag to reschedule unsuccessful exec commands.
Based on the idea of Paul Morel .
The git rebase man git rebase now includes:
--reschedule-failed-exec:: --no-reschedule-failed-exec::
Automatically reschedule the exec commands that failed.
This only makes sense interactively (or when the --exec option was provided).
And:
rebase : enter shortcut for --reschedule-failed-exec
It's a bit cumbersome to write --reschedule-failed-exec before -x <cmd> all the time; Let's present a convenient option to do both at the same time: -y <cmd> .
Note: the first commit was returned to See commit e11ff89 (06 Feb 2019), and the 81ef8ee (10 Dec 2018) commit was returned by Johannes Schindelin ( dscho ) .
(Combined Junio C Hamano - gitster - in commit b966813 , February 09, 2019)
Cancel "rebase: enter shortcut for --reschedule-failed-exec"
This patch was introduced only as a trial “we could introduce a convenient short version if we do not want to change the default behavior in the long run”, opening a discussion about whether other people condemn the current behavior in favor of changing the behavior schedule.
But the consensus on the Git mailing list was that it would be wise to show a warning in the near future and flip default rebase.rescheduleFailedExec to reschedule the rebase.rescheduleFailedExec exec command by default.
So let's get back to the one -y which added the short option -y which we agreed was not necessary or desirable.
Also in Git 2.21 (February 2019): " git rebase -x $cmd " did not reject a multiline command, even if the command is not capable of processing such a command.
It is now rejected in advance.
See Commit c762aad (January 29, 2019) by Philip Wood ( phillipwood ) .
(Combined Junio C Hamano - gitster - in commit 96e6547 , February 7, 2019)
rebase -x : rebase -x check rebase -x
If the user gives an empty argument --exec then git creates a list --exec that it cannot --exec . Rebease starts working before it throws an error:
error: missing arguments for exec error: invalid line 2: exec You can fix this with 'git rebase --edit-todo' and then run 'git rebase --continue'. Or you can abort the rebase with 'git rebase --abort'.
Instead, check for empty commands before rebasing.
Also, make sure that the command does not contain any new lines, since the task list format does not cope with multi-line commands.
Note that this changes the behavior before it can be done:
git rebase --exec='echo one exec echo two'
and it would insert two EXEC lines in the todo list, now it will throw an error.
In Git 2.23, the rebase.rescheduleFailedExec configuration rebase.rescheduleFailedExec should only be effective when performing interactive relocation and should not affect anything when running non-interactive -i, which did not happen.
This has been fixed.
See Commit 906b639 (July 01, 2019) by Johannes dscho ( dscho ) .
(Combined Junio C Hamano - gitster - in commit 64096fb , July 11, 2019)
rebase --am : ignore rebase.rescheduleFailedExec
The exec command is specific to the interactive backend, so it doesn't make sense to the non-traditional guys -i to consider this configuration setting.
We still want to throw an error, unless, of course, the [n02] non-portable reboot starts with --reschedule-failed-exec .
This is reported by Vas Sudanagunta through commit 969de3f .