25

Currently, if I type :Glog I get the list of revisions for the current file.

If I type :Glog -- I get the list of commits for all files.

What do I need to type to get the of commits for the current file?

Kyle Heironimus
  • 7,741
  • 7
  • 39
  • 51

3 Answers3

37

For sake of completeness, once you have the revisions loaded in your buffer, you can browse through them by opening the quickfix list

:Glog -- %
:copen

Load the last 10 commits for the current file

:Glog -10 -- %
lsaffie
  • 1,764
  • 1
  • 17
  • 22
  • 5
    And appending a ! will prevent the first match to open. :Glog! -- % Will just fill the quickfixt list without opening the first. – Daniel May 18 '17 at 09:38
12

I figured it out. I found it here.

:Glog -- %
Kyle Heironimus
  • 7,741
  • 7
  • 39
  • 51
  • How is this the accepted answer when the link referred cites tpope explicitly stating: "Fugitive provides the -- % for you, and if you give a -- yourself, it assumes you want something other than the current file, drops that behavior, and opens the commit instead." – gregory Mar 29 '23 at 04:54
6

I use

:0Gclog

It puts the commits history of current file into quick fix so that you can use ]q or [q to go through them

Note that the usage supports range: :{range}Gclog. So you can use any range, e.g. :1Gclog or use a visual mapping:

vmap <leader>gl :Gclog<CR>
nemo
  • 12,241
  • 3
  • 21
  • 26
  • 1
    What does the number represent? When I tried it here `:0Gclog` populated the quickfix list with the log history and `:1Gclog`, `:2Gclog` etc populated it with the first commit ever. – João Pesce Oct 14 '21 at 21:23
  • 1
    @JoãoPesce The number(s) represents the range in the file to check log for. `0` represents the whole file. Use `:help :Gclog` for the official description. – Yongwei Wu Jan 17 '23 at 03:44