Resolve conflicts using remote changes when pulling from Git remote Resolve conflicts using remote changes when pulling from Git remote git git

Resolve conflicts using remote changes when pulling from Git remote


If you truly want to discard the commits you've made locally, i.e. never have them in the history again, you're not asking how to pull - pull means merge, and you don't need to merge. All you need do is this:

# fetch from the default remote, origingit fetch# reset your current branch (master) to origin's mastergit reset --hard origin/master

I'd personally recommend creating a backup branch at your current HEAD first, so that if you realize this was a bad idea, you haven't lost track of it.

If on the other hand, you want to keep those commits and make it look as though you merged with origin, and cause the merge to keep the versions from origin only, you can use the ours merge strategy:

# fetch from the default remote, origingit fetch# create a branch at your current mastergit branch old-master# reset to origin's mastergit reset --hard origin/master# merge your old master, keeping "our" (origin/master's) contentgit merge -s ours old-master


You can either use the answer from the duplicate link pointed by nvm.

Or you can resolve conflicts by using their changes (but some of your changes might be kept if they don't conflict with remote version):

git pull -s recursive -X theirs