git diff --name-only | uniq | xargs mvim
When git encounters a merge conflict, e.g. during a rebase, it drops you back into the shell with a dirty working directory. I like this one-liner for opening all files with a merge conflict in MacVim.
Once you're in Vim, you can then switch between the files with :n
and :prev
, or another favourite: :w | n
(save current file and open the next command line-supplied file).
UPDATE: see below for a version that works with real terminal commands.
Followed by a bash alias for the editor:
alias conflicts="\$EDITOR \$(git conflicts)"
Also, the diff-filter can be easily altered for editing other categories such as modified files (M) or new files (A). See
git help diff
and search for diff-filter for more options.