Is there a VIM Git timeline?
Asked Answered
C

2

8

So far, I am trying to understand how to use :Glog in combination with :Gdiff, to create a nice overview like the git-time-machine plugin for the Atom editor:

enter image description here

The overview exists of 3 windows

  1. On the left: the current file in the working copy.
  2. On the right: one of the previous versions of the file.
  3. On the bottom: a quickfix list filled with entries from the history.

When I select a commit from the quickfix list, the version will be placed in the right window. Not to forget the difference being highlighted.

Can someone help me? :)

Contrition answered 19/7, 2016 at 20:46 Comment(2)
That's a freaking great idea for a plugin, if it is not there i must try to write it. The best I could fin is a cast using fugitive. Also, we do have vi.SETendency
@Tendency thanks, I did watch the cast. But sadly still have no idea on how to create an overview like this one. Please keep me informed if you will try to create one! :)Contrition
B
7

I'm not aware of a plugin that is exactly like that. But there's gitv, which is like gitk for vim.

screenshot of gitv

Even though it's currently not being actively maintained it's working quite well IMHO.

screenshot of gitv

screenshot of gitv Source

Beestings answered 24/7, 2016 at 1:58 Comment(1)
Thanks, I'll give it a try soon :)Contrition
P
1

Here are some commands that you can use to simulate a crude version of the behaviour you describe.

  • first, open the file that interests you
  • run :only to close any other split windows
  • run :Glog to populate the quickfix list with all past revisions of the file
  • note that you are now looking at the first item in the quickfix list, which should be the most recently committed version of the file
  • traverse forwards and back through the quickfix list using :cnext and :cprev

So far this is basic usage. Now suppose that you find yourself looking at a previous version of the file that you want to diff with the working copy. Here's how you could do that:

  • run :vsplit to divide your workspace into two split windows
  • then <C-w><C-h> to activate the left split
  • then run :Gedit, which loads the working copy version of the file you're looking at
  • then :windo diffthis

Boom! You've got a diff with the working copy on the left and the previous version on the right.

Now let's say that you want to keep the working copy in the left split, while traversing through other past versions in the right split:

  • use <C-w><C-l> to activate the right split
  • use :cprev/:cnext to go back/forwards through the quickfix list (the right split window will move out of diffmode, but the left split remains in diffmode)
  • run :diffthis to activate a diff between the current buffer and the working copy

When you're done looking at diffs, run:

  • :diffoff! to disable diff mode
  • and :only to collapse your workspace into a single split
  • optionally, use :Gedit to switch back to the working copy of the file you're working with

You could automate some of these steps using Vimscript, and you could also add the quickfix window at the bottom of the screen the way you suggested. It would make a neat plugin! Personally, I'm happy to run these commands by hand. This workflow looks complicated when written out, but it can become second nature with practice.

Parker answered 10/1, 2017 at 22:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.