by 1718627440 · 1y ago · 0 comments
vim file/with/typo.txt
git add file/with/typo.txt
git commit --fixup=abcd1234
git rebase --autosquash -i
For some reason I need to pass --interactive/-i, even if I don't actually want it to be interactive. I am not sure if this is just a bug in my Git version or if this is intended.The git commit step can also be replaced with git-absorb, if you have this installed and abcd1234 was the last time you modified these lines.
The second approach is this:
git rebase -i abcd1234~
# do 's/pick abcd1234/edit abcd1234/' in your editor
vim file/with/typo.txt
git rebase --continueSo you would need to stash after the fixup commit and pop the stash after rebase. Or use autostash.
As for effect on the workflow, you can just continue to work and commit and then call autosquash in two weeks, when your about to merge. This also has the benefit, that Git (by default) only alters commits nobody has used yet.
The second approach has the exact same amount of commands. The first has 2 more. The add is necessary, because Git separates committing into two steps, which has other benefits. If you would want the JJ behaviour you can call commit -a. The autosquash is necessary, because you don't need to use fixup with autosquash, you can also do it alone, which is recommended if this fixes something, that is already in an older release.