I love git-revise! It adds the revise subcommand to git which allows to you easily edit commits that aren’t HEAD. I think having a clean git history is especially important for code review and future adventurers so you can figure out why a change was made. With git-revise you can add little fixes you’ve made that relate to an earlier commit of what you were working on with little fuss. You could do this with git-rebase but that requires faffing around with interactive mode, with git-revise it’s as simple as git revise <commit> and anything in staging will be added to that commit. There’s one problem, however. There’s no magit integration for git-revise. I decided to have a go and have created the magit-revise Emacs package.

magit-revise lets you run git-revise on a particular commit just by having your cursor on that row in magit’s log view.

It’s still a work in progress as git-revise has a variety of command line flags to add. Most will be useful and I’ll add them in time.

--cut allows you to break a commit into two. Super useful it you want to go back and break up a “WIP” commit. I’m not exactly sure how this would work with magit because --cut is interactive.

--reauthor updates the author of a commit. This should be pretty easy to implement. I’ve never actually had a use for it so it’ll be pretty low on the list of priorities.

--autosquash squashes commits prefixed with squash! fixup!. Personally, I haven’t been using these but it could be useful to integrate them into my workflow so that I can commit at the end of the day and easily clean up the history when the code is ready for review.

--no-index ignores staged changes. I think this would be useful for when you want to perform one of the other actions (--cut, --reauthor or --autosquash) without also adding the staged files to that commit. Again, probably useful and easy to add. I think I’ll add it before --reauthor but it’s not something I’ve really had to use.

--ref specifies the ref, in most cases the working branch, to update. I’ve only ever used the default: HEAD. This could be useful and would be interesting to add because to do it properly it’d be good to use existing magit facilities for listing the refs.

--edit allows us to edit the give commit. This is like reword but for any commit in the log. I think this will be the next piece of functionality I add because it’s pretty useful, especially when you revise a commit and realise it changes things slightly.

There are others that don’t really make sense to implement for magit: --patch and --interactive. These are already solved by magit. We can add hunks from the diff view, then revise them from the log view.