Skip to content

Menu

Archives

  • July 2026
  • January 2026
  • December 2025
  • August 2025
  • June 2025
  • April 2025
  • July 2023
  • June 2023
  • December 2021
  • October 2021
  • May 2020
  • January 2020
  • October 2019

Calendar

July 2026
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  
« Jan    

Categories

  • AI
  • cloud
  • DB
  • GUI
  • linux
  • Linux Mint
  • logs
  • shell
  • Uncategorized
  • vi

Copyright jaKubu 2026 | Theme by ThemeinProgress | Proudly powered by WordPress

jaKubu
Written by Jakub2026-07-27

Vim in cloud, part 4

cloud . linux . shell . vi Article

Again, this is not about Vim alone, but rather as extension to Git.

If you are dealing with conflicts in a repository, tell Git to use vimdiff (a version of Vim pre-configured for differences already mention in “Vim in cloud, part 2“) as your merge tool. This provides a 3-way merge view:

  1. LOCAL: Your current branch changes.
  2. BASE: The common ancestor before the split.
  3. REMOTE: The changes from the branch you are merging in.

How to set it up:

Run these commands in your terminal to configure Git:

$ git config --global merge.tool vimdiff
$ git config --global mergetool.prompt false

How to use it:

When you encounter a conflict, simply run:

$ git mergetool

Vim will automatically open in a 4-way split (or 3-way depending on configuration). You can navigate between the windows .

To ensure a clear overview of the situation, numbering has been applied to each window.

In the vimdiff merge layout, the bottom window is the MERGED file — the one that gets saved. The three tabs on top are just reference views: LOCAL (yours), BASE (common ancestor), REMOTE (theirs, e.g. main).

Git names these buffers LOCAL, BASE, REMOTE, MERGED, so you can pull entire conflict hunks from either side directly by name. Put your cursor inside the conflicted block in the MERGED window (bottom pane, around line 107), then:

— to accept LOCAL over REMOTE
:diffget LOCAL keep ma.revenue_per_unit, drop ma.return_rate_pct

— to accept REMOTE over LOCAL
:diffget REMOTE keep ma.return_rate_pct, drop ma.revenue_per_unit

Both of these replace the whole conflicted hunk (markers included) with that side’s version.

Just after accepting REMOTE

:wqa – quit the mergetool, saves and quits all windows.

Back in the shell:

git add reports/sales_report.sql
git commit

Keep both?

There’s no single :diffget for “both,” since a hunk-get takes one side’s content wholesale. You resolve it by hand in the MERGED buffer, i.e., manually delete (sequence d , d on each marker line):
<<<<<<< ours
=======
>>>>>>> theirs
marker lines and just leave both column lines:
ma.revenue_per_unit
ma.return_rate_pct
in whatever order makes sense. Since these are two independent added table columns rather than overlapping edits, that’s usually the right call here — you can literally just delete lines 107, 109, and 111 (the markers) and keep 108 and 110.

Extras

A couple of handy hints:

  • IMPORTANT! keys sequnces ] , c / [ , c — jump to next/previous conflict hunk, execute before diffget
  • :diffget BASE — occasionally useful if you want to reject both sides and fall back to the ancestor version
  • git checkout --merge -- <conflicted_file> — reset conflicts, if you accidently jumped out from the mergetool and you get:
    $ git mergetool
    No files need merging

To be continued…

Archives

  • July 2026
  • January 2026
  • December 2025
  • August 2025
  • June 2025
  • April 2025
  • July 2023
  • June 2023
  • December 2021
  • October 2021
  • May 2020
  • January 2020
  • October 2019

Calendar

July 2026
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  
« Jan    

Categories

  • AI
  • cloud
  • DB
  • GUI
  • linux
  • Linux Mint
  • logs
  • shell
  • Uncategorized
  • vi

Copyright jaKubu 2026 | Theme by ThemeinProgress | Proudly powered by WordPress