I'm using a little script to fix up past commits. The script assumes that the fix for the broken commit is staged, that the working directory is clean and that broken commit is passed on the command line. Here's the raw Python core of the script:
#!/usr/bin/env python
import os
import sys
broken_commit = sys.argv[1]
logmsg = os.popen( "git log --format=%%s %s~1..%s" % ( broken_commit, broken_commit ), 'r' ).read().strip()
os.system( "git commit --message \"fixup! %s\"" % logmsg )
os.system( "git rebase --interactive --autosquash %s~2" % broken_commit )
At this point, I'm presented with an editor and just need to confirm (:wq
in my case) the shown changes. How can I avoid this last step? I'd like the git rebase
line to just go on without giving me the chance to edit the steps shown.
I heard you could have special script set via the EDITOR environment variable to achieve. However, I'm using msysGit on Windows, so I'm a bit limited in that area.