Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to merge only remote changes in vimdiff?

After forking a Github repository I performed some changes in it. This was quite some time back, now the upstream branch is well ahead. Thus I wanted to merge those remote changes into my forked repo.

I hit upon a merge conflict in one file only. I went ahead and ran vimdiff as the mergetool to sort these things out. I only want to merge in the remote changes and discard the local ones.

But there are too many conflicting hunks in that file. Selecting changes to merge one by one is tedious to say the least.

  • Is there a shortcut to :diffget RE on all the conflicts in that file?
  • Maybe there is a method to select only a branches diff while discarding the other one in git?
like image 415
devsaw Avatar asked Dec 23 '22 07:12

devsaw


1 Answers

Using Vims global select you can replace all diffs with either LOCAL, BASE or REMOTE

  1. Go to first line in file
:1
  1. Go into visual mode
 <Shift>-V
  1. Go to bottom of file, and select all lines
G
  1. Issue the diffget command on all lines
:diffget REMOTE
like image 122
btburns Avatar answered Dec 26 '22 10:12

btburns