CONFLICT (content): Merge conflict

Both versions changed the same lines in different ways, and git needs you to decide what the file should say before it finishes.

Terminal and GitHub
Auto-merging src/App.tsx CONFLICT (content): Merge conflict in src/App.tsx Automatic merge failed; fix conflicts and then commit the result.

Also appears as

  • CONFLICT (content): Merge conflict in src/App.tsx error: could not apply a24fbd3... Add header
  • error: Pulling is not possible because you have unmerged files. hint: Fix them up in the work tree, and then use 'git add/rm <file>' hint: as appropriate to mark resolution and make a commit. fatal: Exiting because of an unresolved conflict.
  • error: You have not concluded your merge (MERGE_HEAD exists).
  • This branch has conflicts that must be resolved

Prompt to fix it

Git stopped with "CONFLICT (content): Merge conflict in" one or more files. List the conflicted files with git status. For each conflict, read both versions and explain what each side changed, then combine them so neither side’s intended change is lost. Remove every conflict marker, regenerate package-lock.json with npm install if it conflicted, and run the build or tests. Only then mark the files resolved and continue. Don’t resolve everything by picking one side wholesale, and don’t abort without asking me.

Paste into Layerwise or any AI coding tool.

What it means

Git combines two lines of work on its own when they touch different parts of a file. A conflict means both sides changed the same lines, and git can’t know which version is right. It pauses the merge, rebase, or pull and writes both versions into the file: <<<<<<< starts one, ======= separates it from the other, and >>>>>>> ends it. The labels after the markers say where each version came from.

Resolving means editing each marked block into what the code should actually be: one side, the other, or a mix of both. Then you mark the file as resolved with git add and finish with git commit, or with git rebase --continue during a rebase. VS Code and Cursor show buttons above each block to accept either side or both.

Leftover markers are the dangerous part. A stray <<<<<<< HEAD line is a syntax error, so the next build fails, and accepting one side wholesale can quietly drop a fix from the other. Search the project for <<<<<<< before you commit, then run the app. If you get lost, git merge --abort or git rebase --abort puts everything back.

Common causes

  • An AI builder or GitHub’s web editor changed a file on GitHub while you edited the same lines locally.
  • Two branches or pull requests changed the same shared file, like App.tsx, a routes file, or package.json.
  • Both sides added dependencies, so package.json and package-lock.json conflict.
  • A formatter or AI refactor rewrote a whole file on one branch, so every change on the other branch overlaps it.

How to fix it

  1. Run git status to list the files under “Unmerged paths.”
  2. Open each file, find every <<<<<<< block, and edit it into the final code. Delete all three marker lines.
  3. For package-lock.json, resolve package.json first, then run npm install, which repairs a conflicted lockfile for you.
  4. Run git add on each fixed file, then git commit for a merge or git rebase --continue for a rebase.
  5. Check for leftover markers with git grep -n "<<<<<<<", and run the app before you push.

Example fix

git status                # files under "Unmerged paths"

# Edit each file into the final code and delete the markers.
git grep -n "<<<<<<<"     # should print nothing

git add src/App.tsx
git commit                # or: git rebase --continue
All errors
To https://github.com/acme/my-app.git ! [rejected] main -> main (fetch first) error: failed to push some refs to 'https://github.com/acme/my-app.git' hint: Updates were rejected because the remote contains work that you do not hint: have locally. This is usually caused by another repository pushing to hint: the same ref. If you want to integrate the remote changes, use hint: 'git pull' before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Failed to push some refs

GitHub has commits your copy doesn’t, so git refused to overwrite them until you bring those changes in.

Error: Command "npm run build" exited with 1

Command "npm run build" exited with 1

Your build script failed on the host. This line only reports the failure; the actual error is printed earlier in the build log.

fatal: not a git repository (or any of the parent directories): .git

fatal: not a git repository

Git searched this folder and every folder above it and found no repository, so the command has nothing to work on.

remote: error: GH013: Repository rule violations found for refs/heads/main. remote: remote: - GITHUB PUSH PROTECTION remote: ————————————————————————————————————————— remote: Resolve the following violations before pushing again remote: remote: - Push cannot contain secrets remote: remote: remote: (?) Learn how to resolve a blocked push remote: https://docs.github.com/code-security/secret-scanning/working-with-secret-scanning-and-push-protection/working-with-push-protection-from-the-command-line#resolving-a-blocked-push remote: remote: remote: —— OpenAI API Key ———————————————————————————————————— remote: locations: remote: - commit: 3f9c2a1d8e7b6c5a4f3e2d1c0b9a8f7e6d5c4b3a remote: path: .env:2 remote: remote: (?) To push, remove secret from commit(s) or follow this URL to allow the secret. remote: https://github.com/acme/my-app/security/secret-scanning/unblock-secret/2pXk9vQmT4bL7nRw1sYc8ZfHj3e remote: To https://github.com/acme/my-app.git ! [remote rejected] main -> main (push declined due to repository rule violations) error: failed to push some refs to 'https://github.com/acme/my-app.git'

GH013: Push cannot contain secrets

GitHub found an API key or other secret in the commits you tried to push and blocked the whole push so the secret wouldn’t land in the repository.

Build with an agent that checks its work

The Layerwise agent clicks through the live preview and reads the console, so it catches errors before you do.