kota's memex

Status

:G

If there are merge conflicts you can initiate a 3 way merge with dv over a file.

Read other versions of a file

:Gedit HEAD~3:% :Gedit develop:%

Read the index version of a file

Gedit :path/to/file
or for the current file
Gedit :0 or use :Gdiff

Open current file on web frontend (github, gitlab, sourcehut, etc):

:GBrowse

Interactive status screen:

:Gstatus
-       add/reset file (works in visual mode too)
<Enter> open current file in the window below
p       run `git add –patch` for current file
C       invoke :Gcommit

Even better git add -patch

First split the working copy with the version in the index:
:Gdiff

Select some text (or just place your cursor in a hunk to select the whole hunk) and ue the following commands to stage or unstage (checkout) changes interactively:

:diffput 	stage hunk - shorthand :dp
:diffget 	checkout hunk - shorthand :do

Basically, :diffget affects the currently active buffer by getting stuff from the other buffer while :diffput affects the other buffer by putting stuff from the current buffer into it. So the meaning of those commands is reversed if you run them from the pane (left pane) instead of the working pane (right pane).

If the colors get weird while doing this just run :diffupdate.

Resolve merge conflict

Similar to git add patch you can resolve merge conflict using the :diffget and :diffput commands. However, most of the time I like to load the file up normally (conflict markers and all) and use [n and ]n to jump between the markers. You can then use d]n or whatever to delete one of them.

Browsing past versions of a file

:0Gllog: load all previous revisions of the current file into the quickfix list

:0Gllog -10: load the last ten previous revisions of the current file into the quickfix list

:0Gllog -10 --reverse: load the first ten revisions of the current file into the quickfix list (in reverse chronological order)

:0Gllog -1 --until=yesterday: load the last version of the current file that was checked in before midnight last night

Working with the quickfix list

[q 	:cprev  jump to previous quickfix item
]q 	:cnext  jump to next quickfix item
[Q 	:cfirst jump to first quickfix item
]Q 	:clast  jump to last quickfix item