Search code examples
gitgit-pull

how to pull from a branch ignoring all the conflicts from the master


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.'


Solution

  • 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