use fugitive to diff branches or commits

To diff one file with fugitive is quite easy, just use command:

To diff all files between branches or commits is kind of obscure, it took me some time to figure out. Mark down here, hope that it helps others who are using fugitive.

  1. open a total git diff with command Gtabedit 0d39a336b9511af255544fd176816f4a21c199e5(replace 0d39a336b9511af255544fd176816f4a21c199e5 with the branch or the commit id you’d like to diff against). The total diff window is opened as below.

    fugitive_diff_branch

  2. jump to a folded line for some file(such as line 8 in above screenshot), press O to open diff for that file in a new tab.

    fugitive_diff_file