How to go back to the results of :Gblame after selecting a particular commit?
Asked Answered
G

2

10

From the README of the fugitive plugin for vim:

:Gblame brings up an interactive vertical split with git blame output. Press enter on a line to edit the commit where the line changed, or o to open it in a split.

Is it possible to go back to the blame output once I pressed enter on a particular commit?

Gazelle answered 21/7, 2014 at 15:10 Comment(2)
Do you know you are going to return back to the blame? If so you should be using o instead of <cr> to view the commitLangur
@Peter: ok. Can you add this as an answer?Gazelle
S
21

I think what you may be looking for is -

Edit: What you actually want are O and o instead of <CR> if you know you will be going back to the commit.

Here are all the flags for the :Gblame command:

                                           *fugitive-:Gblame*
:Gblame [flags] 
 Run git-blame on the file and open the results in a
 scroll bound vertical split. You can give any of
 ltfnsewMC as flags and they will be passed along to
 git-blame. The following maps, which work on the
 cursor line commit where sensible, are provided:

     g? show this help
     A resize to end of author column
     C resize to end of commit column
     D resize to end of date/time column
     q close blame and return to blamed window
     gq q, then |:Gedit| to return to work tree version
     <CR> q, then open commit
     o open commit in horizontal split
     O open commit in new tab
     - reblame at commit
     ~ reblame at [count]th first grandparent
     P reblame at [count]th parent (like HEAD^[count])

For more information about the commands for Fugitive, look here.

Sixpenny answered 21/7, 2014 at 15:52 Comment(3)
Nope. For me, - opens the previos commit from the file's logGazelle
Oh, are any of the other flags helpful? Because I think that is all there is for the :Gblame command.Sixpenny
I'm glad I was able to help, even though my initial suggestion was incorrect. I'll edit the answer for future people with the same questionSixpenny
B
2

Another option- go to previous buffer using mere vim commands:

Since pressing 'enter' in vim-fugitive opens a new vim buffer on top of the old one- you can simply use vim command to go back:

:b 1 

(go to buffer no. 1).

If already have too many opened buffers, you can list them:

:buffers
Bathetic answered 25/5, 2021 at 5:37 Comment(1)
The problem is that :G blame results in two buffers in a vertical split: one with the blame information alongside (and scroll-bound to) the buffer with the file contents. :b 1 restores only one of those two buffers.Complaint

© 2022 - 2024 — McMap. All rights reserved.