使用CLI mergetool vimdiff时,如何选择完整REMOTE文件作为合并目标?
Accept Entire REMOTE Version in Vimdiff (Git Mergetool)
Absolutely! You don’t have to slog through line-by-line :diffg RE commands—vimdiff has a straightforward way to overwrite the entire merge buffer with the REMOTE version in one go.
Here’s how to do it:
- Make sure you’re in the middle merge window (the one showing the combined file with conflict markers) of your vimdiff session.
- Run the command:
Or use the shorter alias if you prefer::diffget REMOTE:diffg RE - This will instantly replace the entire file with the REMOTE version, wiping out all conflict markers and local changes in one step.
- Save and exit with
:wq—Git will recognize the file as resolved once you close vimdiff.
Bonus Tips for Vimdiff Merges
- If you change your mind and want to revert to the LOCAL version instead, use
:diffget LOCAL(or:diffg LO). - To restore the BASE version (the original file before either branch made changes), run
:diffget BASE(or:diffg BA). - If you ever need to go back to resolving conflicts line-by-line later, you can still use
:diffg REon individual lines by placing your cursor on the target line first.
内容的提问来源于stack exchange,提问作者jsstuball
相关产品推荐
相关产品推荐

