How to force a merge to succeed when there are conflicts?

前端 未结 5 1478
挽巷
挽巷 2020-12-15 04:36

I\'m trying to merge a pull request that has one conflict in one file (see below). The instructions for merging the pull request are provided by github are as follows. Its i

5条回答
  •  悲&欢浪女
    2020-12-15 04:55

    There's no way around resolving conflicts, that's how revision control works (if Alice says "a" and Bob says "b", how should Git know which one is correct unless you tell it?). All you can do is direct git to resolve them itself when merging in one of several possible ways, e.g.

    git merge -s recursive -X theirs 
    

    (-s recursive is the default when there's only one so you can omit it here)

    Now that you already have a conflict in your tree, you either

    • follow the manual resolution route
      • edit the file to your heart's content
      • git add it (add in Git doubles as marking a file resolved)
      • git commit to complete the merge; or
    • restore the pre-merge state with git merge --abort and retry the merge with the above-mentioned auto-resolution options

提交回复
热议问题