Review git-to-be-pushed changes in vim

First, this assume you use fugitive.vim. You don't? I really think you should. If you're still not convinced, have a quick look at the readme, take some time to go over one of the screencast linked there. I personally understood a lot about git index by watching the screencast Working with the git index.

I personnally like to have a look at my patches before giving them to my colleagues, there are a lot of options available to achieve this:

  • starting a gitweb
  • git log -p
  • git show of each commits
  • using tig
  • using fugitive directly in vim

As you may have guessed, my favorite is the last one, for this, I use a small function plus a bind:

fu! GitReview()                                                                 
        Glog --reverse origin/master.. -- .                                     
command Greview call GitReview()                                                
nnoremap <leader>gr :Greview<CR>

This creates the GitReview() function, allows you to call it via :Greview or by the bind gr.

It will do a fugitive :Glog from the head of your current branch to origin/master and show it in reverse order so you start on the first commit after origin/master. This could be improved to do it based on the remotely tracked branch or accept a parameter to specify which branch to start from.

Once you called this, the first patch will be opened, likely with each files touched by the patch folded so you can review them one by one if you want. Following patches are loaded in the quickfixlist, that will likely have opened at the bottom of your vim. If you are not familiar with the quickfix list you can always :h quickfix. Thing to know, you can move forward and backward in this list be it shown or hidden, with :cn and :cp (Next/Prev).

And that's about it for this one. Hope it can be useful to someone!

30 d├ęcembre 2015 13:15:28 -- tags [ vim , git , fugitive , tips ]


Git command typos

Recently beorn shared two git typos on IRC, and I felt it was worth a small post about possible typos and their possible meaning, if any.


git ass

For when you need to get some?


git insect

Ok, this one may be a little far-fetched... still, it il likely you're searching for a bug, aren't you?


git vommit

That one is for when you know your code is really dirty. (you better cleanup before pushing)


git duff

At this stage, its time for a beer. Oh, yeah!


git lag

Maybe too much git duff, or you are just checking how far behing origin/master you are.


git pill

Will you take the red or the blue pill?


git pish

After some git duff you'll have to take a pish, that is how it goes.


git dhow

Doh'! You are about to check how this commit looks like now that you've sober up, not feeling good about it, eh?


git statue

Just having a look at the greatness of what you're actually building, that was worth the efforts!


git tab

Better keep an eye on your tab at Moe's, and make sure Barney hasn't been ordering on your tab.

That's about it, looking at a keyboard, other commands didn't gave me any idea, some are already quite far-fetched and may not have ended up in here, but here they are.

29 octobre 2013 18:41:40 -- tags [ git , command , typos , fun ]