Hands-on task
Squash a fixup commit via autosquash
In /root/repo (branch main) there are three commits: base, add config (creates config.txt with the line value=1) and add readme. There's a mistake in the config — it should be value=2.
Fix it the right way: make a separate fix commit marked as fixup! for the add config commit (with config.txt = value=2), and then non-interactively squash it into the target commit via an autosquash rebase. In the end the history should again consist of three commits (base, add config, add readme), without a separate fixup! commit, and the value=2 change should end up inside the add config commit.
Run the rebase without a manual editor: set GIT_SEQUENCE_EDITOR=true to automatically accept the generated action list.
- git commit --fixup
- autosquash
- git rebase -i
- GIT_SEQUENCE_EDITOR
- rewriting history