According to Cordell

Quick fixup in Vim with fugitive

I am a huge fan of Tim Pope’s fugitive git plugin for Vim. I rarely have to drop out of vim to do any git related functions. However, I found that --fixup is not well supported in fugitive, but can be easily be achieved. One of my workflows with git is to add fixup commits whenever I am doing revisions due to code review or otherwise. When the code is ready for a pull request, I do a rebase with --autosquash and I get a nice clean git history. Technically, I am re-writing history with this flow but I much prefer a clean and organized commit history.

A quick and easy way to fixup involves adding the following to your .vimrc:

map <space>l :Git! log<CR>gg
nnoremap <C-F> yiw <ESC>:Git commit --fixup=<C-r>"<CR>

The first line adds a map for hitting space and then “l” to get a git log. The second triggers a fixup for the word that is under the cursor.

The work flow works like this:

  1. Stage your changes fugitive
  2. Bring up the git log with Space+l
  3. Find the commit you want to fix up and place the cursor on the hash
  4. Hit Ctrl+Shift+f to trigger the fixup