/git-fix

A git command to open merge conflicts in Vim's quickfix list

Primary LanguageShellMIT LicenseMIT

git-fix

A simple git command to open merge conflicts as errors in Vim's quickfix list.

If you're looking for a way to do this from Vim instead of the git CLI, use a plugin like fugitive.

Installation

Using Homebrew:

$ brew install ajvondrak/tap/git-fix

Alternatively, copy bin/git-fix somewhere on your PATH and make sure to give it executable permissions:

$ git clone git@github.com:ajvondrak/git-fix.git
$ cp git-fix/bin/git-fix /usr/local/bin/git-fix
$ chmod +x /usr/local/bin/git-fix

Usage

When you have a merge conflict, git dumps you out into a staging area where all the unstaged files have conflict markers that need to be resolved.

$ git status
On branch main
You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   file

no changes added to commit (use "git add" and/or "git commit -a")

From this point, just run

$ git fix

Under the hood, this will generate a list of messages in the error format %f:%l:%m for each <<<<<<< marker found in the unstaged files. This list is passed into the GIT_EDITOR (presumably something Vim-like) with the -q flag, as well as any other flags you specified on the command line.

For example, if your GIT_EDITOR is the terminal Vim, you might open the quickfix items in GUI Vim with:

$ git fix -g

At any rate, you can then hop between all the merge conflicts in Vim with commands like :cn and :cp.