2017: Rebase should use more the rerere-autoupdate from Git 2.14.x/2.15 onward (Q3 2017).
See commit f826fb7, commit 8d8cb4b, commit 6f0e577, commit 9b6d7a6, commit 5fb415b, commit fd4a3f4 (02 Aug 2017) by Phillip Wood (phillipwood
).
(Merged by Junio C Hamano -- gitster
-- in commit 1016495, 22 Aug 2017)
That is because now:
rebase
: honor --rerere-autoupdate
Rebase accepts '--rerere-autoupdate
' as an option but only honors it
if '-m
' is also given.
Fix it for a non-interactive rebase by passing on the option to 'git am
' and 'git cherry-pick
'.
And:
rebase -i
: honor --rerere-autoupdate
Interactive rebase was ignoring '--rerere-autoupdate
'.
Fix this by reading it appropriate file when restoring the sequencer state for an interactive rebase and passing '--rerere-autoupdate
' to merge and cherry-pick when rebasing with '--preserve-merges
'.
However, as I mentioned here, Starting Git 2.22, Q2 2019, the old rebase
script is no more.
As mentioned by Ohad Schneider in the comments:
Even when I run rebase main --rerere-autoupdate
, I still need to manually execute rebase --continue
upon each conflict, so the original ask of the OP (something like --rerere-autocontinue
) still doesn't exist, right?
It appears to be so: I try the following test script with git version 2.45.2.windows.1 (Q2 2024):
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
echo "**** Creating a new directory for the repository and navigating into it ****"
rm -rf git-rerere-test
mkdir git-rerere-test
cd git-rerere-test
echo "**** Initializing a new Git repository ****"
git -c init.defaultBranch=master init
git config init.defaultBranch master
git config user.name "Test User"
git config user.email "[email protected]"
echo "**** Creating the initial commit on the master branch ****"
echo "Initial content" > F1
git add F1
git commit -m "Initial commit on master"
echo "**** Creating a new branch called 'topic' ****"
git checkout -b topic
echo "**** Committing a change on the topic branch ****"
echo "Content on topic branch" > F2
git add F2
git commit -m "Commit F2 on topic branch"
echo "**** Checking out back to master and making another commit ****"
git checkout master
echo "Different content on master branch" > F2
git add F2
git commit -m "Commit F2 on master branch"
echo "**** Making another commit on the master branch to create a conflict ****"
echo "Content on master branch after F2" > F3
git add F3
git commit -m "Commit F3 on master branch"
echo "**** Going back to the topic branch and making another conflicting commit ****"
git checkout topic
echo "Conflicting content on topic branch" > F3
git add F3
git commit -m "Commit F3 on topic branch"
echo "**** Enabling rerere and autoupdate ****"
git config rerere.enabled true
git config rerere.autoupdate true
echo "**** Attempting to rebase the topic branch onto master with rerere-autoupdate ****"
if git rebase --rerere-autoupdate master; then
echo "**** Rebase completed without conflicts. ****"
else
echo "**** Rebase stopped due to conflicts. Resolving... ****"
fi
# At this point, rerere should have resolved conflicts automatically
echo "**** Checking the status to ensure there are no remaining conflicts ****"
if git rebase --continue; then
echo "**** Rebase continued automatically. ****"
else
echo "**** Rebase requires manual intervention. ****"
exit 1
fi
# Resolve any remaining conflicts manually (if any)
echo "**** Manually resolving any remaining conflicts... ****"
echo "Resolved content" > F2
git add F2
echo "Resolved content" > F3
git add F3
echo "**** Continuing the rebase process ****"
if git rebase --continue; then
echo "**** Rebase completed successfully after manual conflict resolution. ****"
else
echo "**** Rebase failed. Manual intervention required. ****"
exit 1
fi
echo "**** Cleaning up ****"
cd ..
rm -rf git-rerere-test
echo "**** Test repository and files cleaned up. ****"
And I still get "Rebase requires manual intervention" (instead of "Rebase completed successfully after manual conflict resolution"):
C:\Users\vonc\prog\git\so\30771707>bash -c "./testrebrerere.sh t1"
**** Creating a new directory for the repository and navigating into it ****
**** Initializing a new Git repository ****
Initialized empty Git repository in /mnt/c/Users/vonc/prog/git/so/30771707/git-rerere-test/.git/
**** Creating the initial commit on the master branch ****
[master (root-commit) 33cae77] Initial commit on master
1 file changed, 1 insertion(+)
create mode 100644 F1
**** Creating a new branch called 'topic' ****
Switched to a new branch 'topic'
**** Committing a change on the topic branch ****
[topic adee62d] Commit F2 on topic branch
1 file changed, 1 insertion(+)
create mode 100644 F2
**** Checking out back to master and making another commit ****
Switched to branch 'master'
[master e79e48f] Commit F2 on master branch
1 file changed, 1 insertion(+)
create mode 100644 F2
**** Making another commit on the master branch to create a conflict ****
[master 4161fe7] Commit F3 on master branch
1 file changed, 1 insertion(+)
create mode 100644 F3
**** Going back to the topic branch and making another conflicting commit ****
Switched to branch 'topic'
[topic 5a6205f] Commit F3 on topic branch
1 file changed, 1 insertion(+)
create mode 100644 F3
**** Enabling rerere and autoupdate ****
**** Attempting to rebase the topic branch onto master with rerere-autoupdate ****
Auto-merging F2
CONFLICT (add/add): Merge conflict in F2
error: could not apply adee62d... Commit F2 on topic branch
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
Recorded preimage for 'F2'
Could not apply adee62d... Commit F2 on topic branch
**** Rebase stopped due to conflicts. Resolving... ****
**** Checking the status to ensure there are no remaining conflicts ****
F2: needs merge
You must edit all merge conflicts and then
mark them as resolved using git add
**** Rebase requires manual intervention. ****
git rebase -i
in a script (withGIT_SEQUENCE_EDITOR
). So not automatically continuing/skipping resolved conflicts is a PITA, because either I have to do it manually or emulate the nicety ofif ! git rebase […]; then git rebase --abort; fi
with lots ofgit reset
,git cherry-pick
, etc. and thus lots of opportunities to mess up.