CONFLICT (content): Merge conflict in file
This error means Git found conflicting changes in the same lines from two different branches and needs your help to decide which version to keep. Here is how to resolve it.
What this error means
When you run git merge, git rebase, git cherry-pick, or git stash pop, Git tries to combine changes from two sources automatically. When both sources modified the same lines in the same file, Git cannot decide which version is correct and asks you to resolve it.
Why this happens
Two people edited the same lines
You and a teammate both changed the same part of a file on separate branches. When you merge, Git finds two different versions and cannot pick one automatically.
Rebase onto a diverged branch
When you rebase onto a branch that has moved forward, Git replays your commits one by one. If any touch lines also changed upstream, you get a conflict.
Cherry-pick or stash pop conflicts
Cherry-picking or popping a stash applies changes from one context onto another. If the target has diverged from the original context, the same lines may conflict.
How to fix it
The process is the same whether the conflict came from a merge, rebase, or cherry-pick.
Fix during a merge
Open the conflicted file, choose the right version, remove the markers, then stage and commit.
Fix during a rebase (or cancel)
Same process, but finish with git rebase --continue. You can always abort.
How to prevent merge conflicts
Pull and rebase often
The longer your branch diverges, the more likely conflicts become. Run git pull --rebase daily to stay in sync with your team's work.
Keep commits small and focused
Large commits touching many files create more conflict opportunities. Make small changes and merge feature branches back quickly instead of letting them grow.
Communicate with your team
If a teammate is working on the same file, coordinate. Code reviews and short-lived branches reduce the chance of two people editing the same lines.
GitQuest is created by Anaïs (nouvelle fenêtre), web developer and head of education, specializing in tech training and digital accessibility.
Questions about merge conflicts
Master merge conflicts with confidence
Conflicts are not scary once you have practiced them. GitQuest gives you hands-on investigations to resolve real conflicts in a safe environment.
Start practicing