error: patch failed / patch does not apply Git Origin: Build & delivery OSI layer 7 · Application Last updated 25 Nov 2026

error: patch failed: src/app.js:12 error: src/app.js: patch does not apply

A patch can't be applied cleanly to the current files.

Exact message you may see error: patch failed patch does not applygit apply patch does not applyerror: while searching forerror: patch failed: src/app.js:12 error: src/app.js: patch does not apply
Seen on: Git

Meaning

The target file changed since the patch was made. Use git apply --3way, git am -3 or patch --merge, or regenerate the patch from the current base.

Common causes

  • File changed since patch
  • Wrong base commit
  • Whitespace/line endings differ

⚡ Quick fix

  1. git apply --3way patch.diff
  2. git am -3 *.patch
  3. --ignore-whitespace

Detailed fix by platform

Git

  1. git apply --3way --ignore-whitespace fix.patch

How to diagnose

  1. Base — same?
  2. EOL — same?
  3. 3way — used?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Build & delivery. Errors that are often confused with or caused by this one (click to open):

Applying: patch failed. When you have resolved this problem, run git am --continue — Patch failed at 0001 Fix bug. hint: Use 'git am --show-current-patch' to see the failed patch (Git)Applying: patch faile…Authentication failed — fatal: Authentication failed for 'https://github.com/x/y.git/' (Git)Authentication failedAzure DevOps: TF401019 / VS403 push rejected — remote: TF401027: You need the GenericContribute permission to perform this action. (Git)Azure DevOps: TF40101…CONFLICT during cherry-pick — error: could not apply a1b2c3d... Fix login bug / hint: After resolving the conflicts, mark them with git add/rm, then run git cherry-pick --continue (Git)CONFLICT during cherr…GitHub: Sorry, this diff is taking too long to generate — Sorry, this diff is taking too long to generate. The diff is too large to display (Git)GitHub: Sorry, this d…The following paths are ignored by one of your .gitignore files — The following paths are ignored by one of your .gitignore files: dist hint: Use -f if you really want to add them. (Git)The following paths a…unknown revision HEAD — fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree. (Git)unknown revision HEADYou need to start by git bisect start — You need to start by "git bisect start" / We are not bisecting. (Git)You need to start by …error: pa…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.