我们经常发布文档更新,此页面的翻译可能仍在进行中。有关最新信息,请访问英文文档。如果此页面上的翻译有问题,请告诉我们

Resolving a merge conflict on GitHub

You can resolve simple merge conflicts that involve competing line changes on GitHub, using the conflict editor.

此文档对您有帮助吗?

帮助我们创建出色的文档!

所有 GitHub 文档都是开源的。看到错误或不清楚的内容了吗?提交拉取请求。

做出贡献

或, 了解如何参与。

You can only resolve merge conflicts on GitHub Enterprise that are caused by competing line changes, such as when people make different changes to the same line of the same file on different branches in your Git repository. For all other types of merge conflicts, you must resolve the conflict locally on the command line. For more information, see "Resolving a merge conflict using the command line."

If a site administrator disables the merge conflict editor for pull requests between repositories, you cannot use the conflict editor on GitHub Enterprise and must resolve merge conflicts on the command line. For example, if the merge conflict editor is disabled, you cannot use it on a pull request between a fork and upstream repository.

Warning: When you resolve a merge conflict on GitHub Enterprise, the entire base branch of your pull request is merged into the head branch, even if the head branch is the default branch of your repository or a protected branch. Make sure you really want to commit to this branch.

  1. 在仓库名称下,单击 Pull requests(拉取请求)

    议题和拉取请求选项卡选择

  2. In the "Pull Requests" list, click the pull request with a merge conflict that you'd like to resolve.

  3. Near the bottom of your pull request, click Resolve conflicts.

    Resolve merge conflicts button

    Tip: If the Resolve conflicts button is deactivated, your pull request's merge conflict is too complex to resolve on GitHub Enterprise or the site administrator has disabled the conflict editor for pull requests between repositories. You must resolve the merge conflict using an alternative Git client, or by using Git on the command line. For more information see "Resolving a merge conflict using the command line."

  4. 决定您是否想只保持分支的更改、只保持其他分支的更改,还是进行全新的更改(可能包含两个分支的更改)。 删除冲突标记 <<<<<<<, =======, >>>>>>> 并在最终合并中进行所需的更改。

    View merge conflict example with conflict markers

  5. If you have more than one merge conflict in your file, scroll down to the next set of conflict markers and repeat steps four and five to resolve your merge conflict.

  6. Once you've resolved all the conflicts in the file, click Mark as resolved.

    Click mark as resolved button

  7. If you have more than one file with a conflict, select the next file you want to edit on the left side of the page under "conflicting files" and repeat steps four through seven until you've resolved all of your pull request's merge conflicts.

    Select next conflicting file if applicable

  8. Once you've resolved all your merge conflicts, click Commit merge. This merges the entire base branch into your head branch.

    Resolve merge conflicts button

  9. If prompted, review the branch that you are committing to. If you want to commit to this branch, click I understand, update BRANCH.

    Merge conflict confirmation window

  10. To merge your pull request, click Merge pull request. For more information about other pull request merge options, see "Merging a pull request."

Further reading

此文档对您有帮助吗?

帮助我们创建出色的文档!

所有 GitHub 文档都是开源的。看到错误或不清楚的内容了吗?提交拉取请求。

做出贡献

或, 了解如何参与。