-
Notifications
You must be signed in to change notification settings - Fork 4
Resolving Merge Conflicts
Merge conflicts happen when Git cannot automatically combine changes from different branches.
They are a normal part of collaboration β especially when several students work in the same files.
This guide explains:
- How to resolve simple merge conflicts directly on GitHub
- When you must resolve conflicts locally
- Best practices to avoid merge conflicts in the future
Common causes include:
- Two people editing the same lines in a file
- A file being deleted or renamed in one branch but modified in another
- Long-running branches that fall behind
developormain
Learning to resolve conflicts is an essential skill for developers.
GitHub allows you to resolve competing line changes (simple conflicts) using its built-in conflict editor.
You can only use this method if:
- Both branches changed the same specific lines,
- And GitHub detects that the conflict can be manually corrected in the browser.
For more complex conflicts, you must resolve them locally.
Official GitHub docs:
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-on-github
-
In your repository, click Pull requests.
-
Select the pull request with the merge conflict.
-
Scroll to the bottom and click Resolve conflicts.
Note: If the button is disabled, the conflict is too complex for the GitHub editor.
You must resolve it on your computer using Git. -
Inside the conflict editor, choose how you want to merge the conflicting changes:
- Keep your branchβs changes
- Keep the other branchβs changes
- Combine and rewrite both changes
-
Remove the conflict markers.
-
Repeat for all conflicts in the file.
-
Click Mark as resolved.
-
If multiple files have conflicts, repeat the steps for each file.
-
When everything is resolved, click Commit merge.
-
If prompted, confirm whether to update the existing branch or create a new one based on repository protections.
-
Once the conflict is resolved, you can Merge pull request as usual.
GitHub cannot resolve:
- Structural changes
- File deletions
- File renames
- Complex multi-file conflicts
- Conflicts involving binary files (images, audio, etc.)
In these cases, resolve conflicts on your machine.
GitHubβs guide for local conflict resolution:
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line
- Pull from
developormainfrequently to prevent your branch from falling behind. - Keep your pull requests small to reduce the risk of merge conflicts.
- Use Draft Pull Requests so conflicts are detected early.
- Communicate with teammates when working in the same file or feature area.
- Resolve conflicts locally when the changes are complex (recommended).
- After resolving conflicts, always run and test the project before pushing.
- Read conflict markers carefully and remove all of them.
| Mistake | Why It Matters |
|---|---|
| Ignoring conflict warnings | Blocks your PR from being merged and slows the team |
Leaving conflict markers in the code (<<<<<<<, =======, >>>>>>>) |
Causes compile errors and CI/CD failures |
| Trying to resolve complex conflicts on GitHub | Can break logic or overwrite important code |
| Working on outdated branches | Greatly increases conflict frequency |
| Combining multiple issues into one branch | Leads to large conflict-heavy PRs |
| Accepting changes without reviewing both sides | Can accidentally delete important code |
β‘οΈ Proceed to: PR Review Process
Home β’ New Student Onboarding β’ Guides β’ Projects β’ Code of Conduct β’ FAQ
Last updated: 12/7/2025



