I usually submit a list of commits for review. If I have the following commits:
HEAD
Commit3
Commit2
To get a non-interactive command, put a script with this content in your PATH:
#!/bin/sh
#
# git-fixup
# Use staged changes to modify a specified commit
set -e
cmt=$(git rev-parse $1)
git commit --fixup="$cmt"
GIT_EDITOR=true git rebase -i --autosquash "$cmt~1"
Use it by staging your changes (with git add
) and then run git fixup
. Of course, it will still be interactive if you get conflicts.