kieranpotts / dotfiles

A baseline, extensible UNIX user configuration.
MIT License
1 stars 0 forks source link

Edit then add conflicting files #207

Open kieranpotts opened 1 year ago

kieranpotts commented 1 year ago

You get a lot of merge conflicts and want to quickly solve them using an editor and then add the conflicted files. Try this:

[alias]
        edit-unmerged = "!f() { git diff --name-status --diff-filter=U | cut -f2 ; }; vim `f`"
        add-unmerged = "!f() { git diff --name-status --diff-filter=U | cut -f2 ; }; git add `f`"

You should replace "vim" by your favorite editor.

Then just use

$ git edit-unmerged
... edit ...
$ ... test ...
$ git add-unmerged
$ git commit  # or git rebase --continue or whatever

Source: https://git.wiki.kernel.org/index.php/Aliases

kieranpotts commented 1 year ago

To add all conflicting files at once:

git diff --name-only --diff-filter=U | uniq  | xargs $EDITOR