Hacker News new | ask | show | jobs
by dr4g0n 4030 days ago
It's not exactly hard to do by hand:

    git add ...
    git commit --fixup $SHA
    git stash
    git rebase -i --autosquash $SHA~
    git stash pop
3 comments

Or simply:

    git add ...
    git commit --fixup $SHA
    git rebase -i --autosquash --autostash $SHA~
It gets more complicated if you have some other modified content that you wanna leave untouched. You then need to stash it or commit it separately.

The point of the alias is to make it all more user-friendly and less error-prone.

That's what the `--autostash` is for. It also has the advantage that the stash will be restored at the end of the rebase even if it hits problems and needs to be continued or aborted.
You can even use --autostash to avoid the manual stash, and if you're doing this a lot then the config options rebase.autosquash and rebase.autostash are your friends.
Nice! wasn't familiar was autostash.
Or, alternatively, just git rebase -i, mark the comment for amending with "e", then when it stops for amending amend what you need and commit with "git commit --amend", then "git rebase --continue" to finish. Wrap with stash if you don't have a clean working directory to start with.
That's what I do right now, leading to temporary commits like "Squash me" followed by the kinda awkward interactive rebase flow, which is the only instance where I use Vim, and awkwardly and with some resistance at that.
My method does not lead to any temporary commits.