Fix: CONFLICT (content): Merge conflict in …
Two branches changed the same lines and Git cannot choose for you. Open the file, keep the right text, remove the markers, then stage it and finish the merge or rebase.
A conflict is not an error in your repository. It is Git asking a question it cannot answer alone: both sides changed the same part of a file, so which version is right?
Auto-merging config.toml
CONFLICT (content): Merge conflict in config.toml
Automatic merge failed; fix conflicts and then commit the result.
The same message appears during git merge, git pull, git rebase, git cherry-pick, and git stash pop.
1. See what is conflicted
git status
git diff --name-only --diff-filter=U
Conflicted files are listed under Unmerged paths as both modified (UU in git status --short).
2. Edit the file
Git wrote both versions into the file between markers:
title = "Shop"
<<<<<<< HEAD
color = "green"
=======
color = "red"
>>>>>>> feature/red
The part above ======= is the branch you are on (HEAD); the part below is the incoming change. Replace the whole block, markers included, with the text that should survive. That may be one side, the other, or a mix of both. Then search the file for <<<<<<< to be sure none are left.
3. Mark it resolved and continue
git add config.toml
git commit --no-edit # finishing a merge
# or, during a rebase:
git rebase --continue
Run your tests before continuing. A file without markers can still be wrong if the two changes do not work together.
Taking one side for a whole file
git restore --ours config.toml
git restore --theirs config.toml
Careful: during a rebase the meaning flips. Ours is the branch you are rebasing onto, and theirs is your own commit being replayed. If you picked the wrong side, git restore --merge config.toml brings the conflict markers back.
Changed your mind? Back out
git merge --abort
git rebase --abort
git cherry-pick --abort
Each one returns the repository to how it was before the operation started.
Other kinds of conflict
CONFLICT (add/add): both sides created a file with the same name. Resolve it like a content conflict.CONFLICT (modify/delete): one side edited a file, the other deleted it. Keep it withgit add file, or confirm the deletion withgit rm file.CONFLICT (rename/rename)and similar: rungit status, which explains what each side did.
Make conflicts easier to read
Setting git config --global merge.conflictStyle zdiff3 adds a third section between ||||||| and ======= showing the original text before either side changed it. Seeing what both sides started from often makes the right answer obvious. Editors such as VS Code also show conflicts with buttons to accept either side.
Conflicts become rarer and smaller when branches are short-lived and you pull from main often.
See also
- 0034 Merging vs rebasing in Git Merge and rebase both bring commits from one branch into another. Merge keeps history exactly as it happened; rebase replays your commits… Intermediate · Concept · Any system Article Branching & rebasing 15 Oct 2026
- 0040 Fix: error: failed to push some refs to … Git refused your push, usually because the remote branch has commits you do not have yet. Bring them in, combine them with… Beginner · Fix · Any system Article Common errors 15 Oct 2026
- 0042 Fix: fatal: refusing to merge unrelated histories Your local repository and the remote do not share a single commit, usually because both were started separately. Allow the one-time merge,… Intermediate · Fix · Any system Article Common errors 15 Oct 2026
- 0262 Make your first pull request: Git and GitHub from first commit to merged change A complete beginner's path through Git and GitHub: set up Git, make commits, ignore files, use branches, push to GitHub, open a… Beginner · Tutorial · Any system Article Branching & rebasing · Pull requests · Setup 15 Oct 2026
History
Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.
- commitpedia-admin +2,735 chars