How to fix CONFLICT (content): Merge conflict in file.txt error: could not apply abc1234... commit message in Git

GitINTERMEDIATELOWUpdated Dec 6, 2025ยท 202 views

This error occurs when Git cannot automatically apply a commit during a rebase because changes in the commit conflict with changes in the target branch. You must manually resolve the conflicts by editing the affected files, staging them, and continuing the rebase.

Quick fix

Fixes CONFLICT (content): Merge conflict in file.txt error: could not apply abc1234... commit message

git status
  1. Identify conflicting files
  2. Open and examine the conflicted files
  3. Resolve the conflicts
  4. Stage the resolved files
git โ€” error
git status
CONFLICT (content): Merge conflict in file.txt error: could not apply abc1234... commit message

What this error means

When you run `git rebase`, Git takes each commit from your branch and attempts to replay it on top of the target branch. If a commit modifies the same lines of code that were also changed in the target branch, Git cannot determine which version to keep automatically. The message "CONFLICT (content): Merge conflict in file.txt" tells you which file has conflicting changes. The "error: could not apply abc1234" portion identifies the specific commit that Git couldn't apply cleanly. Inside the conflicted file, you'll find conflict markers (`<<<<<<<`, `=======`, `>>>>>>>`) showing both versions of the code. This is a normal part of the rebase workflow, not a fatal error. Git pauses the rebase and waits for you to manually decide how to combine the conflicting changes before continuing.

Typical symptoms

  • Rebase operation stops midway with CONFLICT message
  • Files contain conflict markers (<<<<<<<, =======, >>>>>>>)
  • git status shows 'both modified' files in red
  • git rebase --continue fails with 'You must edit all merge conflicts'
  • IDE or editor highlights conflict regions in the affected files

Common causes

  1. The same lines of code were modified in both your branch and the target branch
  2. A file was renamed or moved in one branch while edited in another
  3. Multiple commits in your branch modify the same file that changed in the target
  4. Long-running feature branches that diverged significantly from main
  5. Rebasing onto a branch with many changes since your branch was created
  6. Previous merge conflict resolution was lost due to history rewriting

How to fix "CONFLICT (content): Merge conflict in file.txt error: could not apply abc1234... commit message"

1Identify conflicting files

When Git reports a conflict, first check which files need attention:

bash
git status

Files listed under "Unmerged paths" or showing "both modified" need conflict resolution. You can also see the current failing patch:

bash
git am --show-current-patch
2Open and examine the conflicted files

Open each conflicted file in your editor. You'll see conflict markers like this:

bash
<<<<<<< HEAD
// This is the code from the target branch (already rebased commits)
const result = calculateTotal(items);
=======
// This is the code from your commit being applied
const result = computeSum(items);
>>>>>>> abc1234 (commit message)

The section between <<<<<<< HEAD and ======= shows the target branch version.
The section between ======= and >>>>>>> shows your commit's version.

Important during rebase: "HEAD" refers to the rebased state so far, not your original branch. "Theirs" and "ours" are swapped compared to merge conflicts.

3Resolve the conflicts

Edit each conflicted file to create the correct final version:

1. Remove all conflict markers (<<<<<<<, =======, >>>>>>>)
2. Keep the code you want (could be from either version or a combination)
3. Save the file

Example resolution:

javascript
// Final resolved version - combining both changes
const result = calculateTotal(items); // Kept the better function name

For simple cases, you can use Git's built-in tools:

bash
# Keep your version (the commit being rebased)
git checkout --theirs path/to/file.txt

# Keep target branch version
git checkout --ours path/to/file.txt

Or use a visual merge tool:

bash
git mergetool
4Stage the resolved files

After editing each conflicted file, stage it to mark as resolved:

bash
git add path/to/file.txt

Or stage all resolved files at once:

bash
git add -A

Verify all conflicts are resolved:

bash
git status

There should be no files under "Unmerged paths".

5Continue the rebase

Once all conflicts are resolved and staged, continue the rebase:

bash
git rebase --continue

Git will apply the resolved commit and move to the next one. If more conflicts arise, repeat the resolution process.

If you get "No changes - did you forget to use 'git add'?": This means the resolved version is identical to the target branch. You can skip this commit:

bash
git rebase --skip
6Abort if needed

If the conflicts are too complex or you want to start over, abort the rebase:

bash
git rebase --abort

This returns your branch to its exact state before the rebase started. You can then:
- Try a different approach (merge instead of rebase)
- Break up your changes into smaller commits
- Coordinate with teammates about conflicting changes

Advanced notes

### Enable diff3 for Better Conflict Context

The default conflict view only shows two versions. Enable diff3 to see the common ancestor:

bash
git config --global merge.conflictstyle diff3

Conflicts will then show three sections, including what the code looked like before either branch changed it. This makes it much easier to understand what changed and why.

### Enable rerere to Record Resolutions

Git can remember how you resolved conflicts and automatically apply the same resolution if it sees the same conflict again:

bash
git config --global rerere.enabled true

This is especially useful when rebasing repeatedly or dealing with long-running branches.

### Understanding "Ours" vs "Theirs" in Rebase

During a rebase, the terminology is counterintuitive:
- "ours" = the target branch (where you're rebasing onto)
- "theirs" = your commits being replayed

This is the opposite of merge conflicts. Keep this in mind when using --ours or --theirs flags.

### Squash Before Rebasing

If you have many small commits that touch the same files, consider squashing them first:

bash
git rebase -i HEAD~5  # Interactive rebase last 5 commits

Mark commits as "squash" or "fixup" to combine them. Fewer commits means fewer potential conflicts during the main rebase.

### Rebase Frequently to Minimize Conflicts

The longer your branch diverges from the target, the more likely you'll face conflicts. Rebase regularly:

bash
git fetch origin
git rebase origin/main

Small, frequent rebases are easier than one large rebase with many conflicts.

Frequently asked questions

What does "CONFLICT (content): Merge conflict in file.txt error: could not apply" mean?
When you run git rebase, Git takes each commit from your branch and attempts to replay it on top of the target branch. If a commit modifies the same lines of code that were also changed in the target branch, Git cannot determine which version to keep automatically. txt" tells you which file has conflicting changes.
How do I fix "CONFLICT (content): Merge conflict in file.txt error: could not apply"?
This error occurs when Git cannot automatically apply a commit during a rebase because changes in the commit conflict with changes in the target branch. You must manually resolve the conflicts by editing the affected files, staging them, and continuing the rebase.
What causes "CONFLICT (content): Merge conflict in file.txt error: could not apply"?
The same lines of code were modified in both your branch and the target branch A file was renamed or moved in one branch while edited in another Multiple commits in your branch modify the same file that changed in the target
Is the "CONFLICT (content): Merge conflict in file.txt error: could not apply" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading