GitHub: a pull request has merge conflicts
Merge conflicts happen when people make different changes to the same line of the same file, or when one person edits a file and another deletes it. Git cannot safely choose which version to keep, so all conflicts must be resolved before a pull request can be merged on GitHub: while it has a conflict between the compare branch and the base branch, Merge pull request is deactivated (GitHub's merge conflicts, checked October 27, 2026).
$ git merge BRANCH-NAME > CONFLICT (content): Merge conflict in styleguide.md > Automatic merge failed; fix conflicts and then commit the result
Two kinds of conflicts
- Competing line changes: both branches changed the same lines. In the file, the changes from HEAD or the base branch come after
<<<<<<< HEAD, then=======, then the changes from the other branch and>>>>>>> BRANCH-NAME. - See the original too: the default markers do not show what the original said in the conflicting area. With
git config merge.conflictStyle diff3(orzdiff3), a|||||||section with the common ancestor's version comes before=======(Git's how conflicts are presented). - A removed file: one branch deletes a file that the other branch edits.
git statuslists it under the unmerged paths, for example asdeleted by us.
To see conflicts first among what blocks a merge: Pull Request Inbox for GitHub, a plugin for JetBrains IDEs, names conflicts with the target branch first in its merge checks, and says to resolve them on GitHub or merge the target branch in locally and push.
Resolving on GitHub
- The conflict editor: simple competing line change conflicts can be resolved on GitHub. Near the bottom of the pull request, click Resolve conflicts, keep one side, the other, or a new change, delete the conflict markers, click Mark as resolved for each file, then Commit merge (GitHub's resolving a merge conflict on GitHub).
- Resolve conflicts deactivated: other conflicts, such as a removed file, are resolved with another Git client or on the command line.
- The whole base branch: resolving conflicts on GitHub merges the entire base branch into the head branch. If the head branch is the default branch or a protected branch, you may be asked to create a new head branch, and for a protected head branch you must: Create branch and update my pull request.
- Fix with Copilot: on GitHub.com and GitHub Enterprise Cloud, if Copilot cloud agent is enabled for the repository, the merge box shows a Fix with Copilot button. You can also ask
@copilotin a pull request comment to fix the conflicts. Copilot resolves them, checks that the build, tests and linter still pass, and requests your review before you merge (GitHub's Copilot docs). - GitHub Enterprise Server: a site administrator can turn off the conflict editor for pull requests between repositories, such as from a fork. Those conflicts are resolved on the command line.
Resolving on the command line
- Competing lines:
git statuslists the files asboth modified. Edit each file, delete the conflict markers, thengit add .andgit commit. - Take one side for a file:
git checkout --ours FILEorgit checkout --theirs FILEchecks out stage #2 (ours) or #3 (theirs) for unmerged paths. Duringgit rebaseandgit pull --rebasethey may appear swapped:--oursgives the version from the branch the changes are rebased onto, and--theirsthe version from the branch with your work being rebased (Git's git checkout). - A removed file:
git add FILEkeeps it andgit rm FILEremoves it; then commit. - Back to the pull request: push the resolution to the pull request branch, then merge the pull request (GitHub's resolving a merge conflict using the command line).
- After a rebase instead: when
git rebasestops on a conflict, Git names the commit it could not apply (error: could not apply SHA...) and gives three choices: fix the conflict as above and rungit rebase --continue, rungit rebase --skipto leave out that commit's changes entirely (rarely the one to choose), or rungit rebase --abortto return the branch to where it was before the rebase (GitHub's resolving merge conflicts after a Git rebase). GitHub calls rebasing commits you have already pushed bad practice, because changing the history can make things difficult for everyone else using the repository (about Git rebase).
What to do
- Simple line conflicts: Resolve conflicts on the pull request page, then Merge pull request.
- Anything else: in a local clone, merge the base branch into the pull request branch, resolve the conflicts, commit and push back to the pull request branch.
- Not Update branch: GitHub updates a branch only when there are no merge conflicts, and refuses with
merge conflict between base and headotherwise (see why updating the branch was refused). - Ask the API whether it can merge: when you get, create or edit a pull request, GitHub makes a test merge commit, added to neither branch, and reports it in
mergeable:true,false, ornullwhile a background job is still computing it, in which case ask again after a while. When it istrue,merge_commit_shais the test merge commit (GitHub's REST API endpoints for pull requests). - With
gh pr merge: when GitHub reports the merge stateDIRTY, the GitHub CLI stops withPull request OWNER/REPO#N is not mergeable: the merge commit cannot be cleanly created., and--admindoes not get past it. Run without--repoin a clone with a remote for the base repository, it also prints the commands to resolve the conflicts locally:gh pr checkout N && git fetch REMOTE BASE && git merge REMOTE/BASE, withgit rebasein place ofgit mergewhen you asked for--rebase(pkg/cmd/pr/merge/merge.go). - The same conflicts after a squash merge: if you keep working on a branch that was squash merged, later pull requests can include the squashed commits again, which makes conflicts more likely and can mean resolving the same conflicts more than once (see commits already squash merged in the next pull request).
- Let Git reuse a resolution: once the configuration variable
rerere.enabledis set,git rerererecords the conflicted automerge results and your hand resolutions on the first manual merge, and applies the recorded resolutions when the same conflicts come back (Git's git rerere).
In IntelliJ IDEA: "Branch has conflicts that must be resolved"
The GitHub pull requests built into IntelliJ IDEA show "Branch has conflicts that must be resolved" in a pull request's status, with a Resolve link. In the source (checked October 30, 2026), the line shows when GraphQL gives the pull request's mergeable as CONFLICTING ("The pull request cannot be merged due to merge conflicts"). While it is UNKNOWN ("The mergeability of the pull request is still being calculated"), or before the answer has come, the line reads "Checking branch for conflicts" instead (GitHub: MergeableState; IntelliJ IDEA: GHPRMergeabilityStateBuilder.kt, GHPRResolveConflictsLocallyViewModelImpl.kt, CodeReviewDetailsStatusComponentFactory.kt). Resolve asks whether to rebase or merge, fetches the base branch, checks out the pull request branch, and then rebases it onto the base branch or merges the base branch into it. Any conflicts are then resolved in the IDE, and the pull request changes only when you push; after a rebase, that push has to be a force push (ResolveConflictsLocallyViewModel.kt). Resolve is greyed out, with the reason on it, for example while the repository is in the middle of a merge or a rebase ("Merge is already in progress"), and when the current branch already tracks the pull request branch and has the latest commit of the base branch in its history ("Already resolved locally, push your changes to resolve") (CollaborationToolsBundle.properties). There is an open report that "Checking branch for conflicts" stays on a pull request after it is merged (IJPL-162938, open on October 30, 2026).
GitHub pull requests in IntelliJ IDEA
Pull Request Inbox for GitHub, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, shows a pull request's reviews, checks and conversations next to the diff, and merges it with the methods the target branch allows. Its merge checks say when a pull request has conflicts with the target branch, among the ones that block the merge, which come first, and say to resolve them with Resolve conflicts on GitHub or to merge the target branch into the branch locally and push; it does not offer Update the branch while the pull request conflicts, as GitHub refuses it. The review inbox, diffs and conversations are free; approving, commenting, resolving and merging are Pro (US$1.50 a month, with a 30-day trial).
Get it on JetBrains Marketplace
GitHub is a trademark of GitHub, Inc.; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by GitHub, Inc. or JetBrains.
More: GitHub merge refused (405, 409) · GitHub review refused (422) · GitHub search 422 "Validation Failed" · "Resource not accessible by personal access token" · 401 "Bad credentials" · "Resource protected by organization SAML enforcement" · "API rate limit exceeded" · GitHub diff 406 "too_large", 3,000 files · GitHub line comment 422 "must be part of the diff" · GitHub branch update refused (422) · GitHub pull request not created (422, 403) · GitHub auto-merge refused · GitHub draft, ready for review or close refused · GitHub conversation not resolved · GitHub checks not shown (check runs 403) · GitHub file contents not read · GitHub compare refused (404, 422) · GitHub comment or reply refused (403 locked, archived) · GitHub merge method not allowed (405) · GitHub branch not found (404, 301) · GitHub Enterprise Server not reached · GitHub review request not shown · GitHub pull request list incomplete · GitHub 404 Not Found, renamed repositories (301, 307) · GitHub line comment outdated or not on the diff · GitHub pull requests not updating, notifications late · GitHub suggested change cannot be applied · GitHub required check stuck at "Expected" · GitHub code owner review required · GitHub merge blocked by unresolved conversations · GitHub merge blocked by unsigned commits · GitHub branch that merges through a merge queue · GitHub merge waiting for an approval of the most recent push · GitHub merge waiting for code scanning results · GitHub merge waiting for code quality results · GitHub merge blocked by a code coverage threshold · GitHub merge blocked by license compliance results · GitHub branch locked or its updates restricted · GitHub branch not deleted after merging · GitHub merge waiting for a team's approval (Required reviewers) · GitHub merge blocked by secret scanning alerts · GitHub stacked pull request not merging · GitHub push blocked by push rules · GitHub merge blocked by commit metadata rules · GitHub force push blocked · GitHub issue not closed by a merged pull request · GitHub pull request not checked out locally · GitHub changes requested and dismissing a review · GitHub co-author not credited for a commit · GitHub dependency review check failed · GitHub Dependabot not rebasing its pull request · GitHub fork not syncing with upstream · GitHub pull request base branch not changing · GitHub pull request not reverting · GitHub pull request template not showing · GitHub pull request labels or assignees not added · GitHub pull request not closing or reopening · GitHub push blocked by push protection · GitHub pull request comment hidden · GitHub pull request blocked until deployments succeed · GitHub team review request replaced by members · GitHub pull request file no longer marked Viewed · GitHub pull request marked merged without being merged · GitHub Copilot review does not count as an approval · GitHub checks not running on a pull request a workflow created · GitHub Update branch button not shown on a pull request · GitHub checks failing on a Dependabot pull request · GitHub checks failing on a pull request from a fork · GitHub checks skipped by [skip ci] in a commit message · GitHub checks gone after the retention period · GitHub code review limits in a public repository · GitHub pull requests turned off or limited in a repository · GitHub checks run on every pull request in a stack · GitHub pull request showing commits already squash merged · GitHub pull request not showing a file diff · GitHub push to a pull request branch from a fork refused · GitHub check cancelled on a pull request · GitHub Rebase and merge not available · GitHub merge commit message not what you expected · GitHub pull request shows every line changed · GitHub API request timed out · GitHub pull request image or document diff not shown · GitHub review request refused (422) · GitHub pull request from Copilot: checks not running, approval not counted · GitHub push refused: GH006 and GH013 on a protected branch · GitHub "At least 1 approving review is required", approvals that do not count · GitHub pull request plugins for IntelliJ IDEA, compared · 日本語