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
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
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:
- Stage your changes fugitive
- Bring up the git log with
- Find the commit you want to fix up and place the cursor on the hash
Ctrl+Shift+fto trigger the fixup