4

After git pull origin branch-name on local master branch, I got an error which says 'Automatic merge failed; fix conflicts and then commit the result.' as the branch is several commits ahead and several behind the master. If I want to takes all changes from the remote branch and ignore conflicts, where should I do?

I tried git merge --strategy-option theirs which returns error 'error: Merging is not possible because you have unmerged files.'

santoku
  • 3,297
  • 7
  • 48
  • 76
  • Possible duplicate of [How do I force "git pull" to overwrite local files?](https://stackoverflow.com/questions/1125968/how-do-i-force-git-pull-to-overwrite-local-files) – Pavel Anikhouski Jul 10 '19 at 20:14
  • 1
    If you didn’t have any uncommitted changes before pulling, you can `git reset --hard HEAD` and then do the merge. – Ry- Jul 10 '19 at 20:17
  • I did that, and still shows 'fix conflict and commit the result'. I have no local changes except a master that differs from the branch – santoku Jul 10 '19 at 20:20
  • 2
    Sorry, `git merge --abort`, actually. – Ry- Jul 10 '19 at 20:27

1 Answers1

17

Generally, if you want to blow away any local changes and just update to the remote master branch, this would work:

git fetch
git reset --hard origin/master

If you have local changes that you want to clean, you might have to do the following first:

git reset --hard
git clean -df
idlethread
  • 1,111
  • 7
  • 16
  • thanks. this worked. what if I want to take a certain remote branch (non-master) and compare it with current master to check the changes? – santoku Jul 10 '19 at 20:27
  • Depending on how you want to see those changes, you could do git log HEAD.. or git diff HEAD.. – idlethread Jul 10 '19 at 20:33