Git Patch and Diff Viewer (Apply, Reverse, Split)
Read, apply, reverse and split git patches in the browser, no repository needed.
Free preview.
- Free preview: every count and file of the patch, the diffs of the first files under a MySmartCoPilot mark (up to 3) and the first lines of a patched file (up to 20).
- Locked until you unlock it: download and copy.
- Unlock: Pro pass, ₹179 for 30 days, a one-time payment that never renews.
Ways to unlock shows how to get the full result.
Printing this result is locked in the free preview.
git diff, git format-patch (one or a whole series, also as one mbox file), or diff -u output. Several files can be opened at once.
Summary
Apply to the original file
Paste or open the file the patch was made for. Nothing leaves your browser.
Patched file
Locked in the free preview. Opens the ways to unlock this result.
Locked in the free preview. Batch runs unlock with a pass.
Locked in the free preview. Query results unlock with a pass.
About the Git Patch and Diff Viewer (Apply, Reverse, Split)
Read a .patch or .diff file the way a code review shows it: every changed file with its additions and deletions, each hunk side by side or inline, with syntax colours and the changed words marked. A git format-patch series shows each commit’s subject, author, date and message, and its diffstat.
Then use the patch without a repository: apply it to the original file you paste or open, with a report of every hunk (applied, moved by an offset, applied with fuzz, already applied, or failed and why, with the closest place in the file); reverse it to undo a change; or split a multi-file patch or a series into one patch per file or per commit, as a ZIP. Whitespace and line-ending problems that make git apply refuse a patch are pointed out.
Patches and files stay in your browser. To make a patch from two texts, use Text Diff.
Without a pass the result is a free preview: every count and file, the diffs of the first files under a mark (up to 3) and the first lines of a patched file (up to 20). The other diffs, the whole patched file and every download, ZIP and copy unlock with a Pro pass.
How to use it
- Paste the patch, or open one or more
.patch/.difffiles (a series opens in file-name order). An mbox fromgit format-patch --stdoutworks too. - Read the summary (commits, files, lines added and removed) and any problems, then each file’s changes. Switch between Side by side and Inline, and turn on Wrap long lines on narrow screens.
- To apply it, choose the file in the patch, paste or open the original file, and press Apply. The report lists each hunk; the patched file and the
.rejfile of hunks that failed download with a Pro pass. - With a pass, Reversed .patch gives a patch that undoes this one, and the ZIP buttons split it per file or per commit (each part keeps its commit’s headers, so
git amstill reads it).
Examples
Patch: @@ -1,5 +1,5 @@ … (changes line 2) Original file: three new lines at the top, then the old content
Hunk 1 applied at line 4 (offset +3 lines): the file has more lines above it than the patch expects.
Patch removes “line two”, but the file says “line TWO”
Hunk 1 (@@ -1,5 +1,5 @@) does not apply. The closest place is line 1, where 4 of 5 lines match; line 2 should be “line two” but is “line TWO”.
The file was edited after the patch was made: fix the line, or rebuild the patch from the current file.
Common uses
- Reviewing a patch sent by e-mail or attached to an issue without cloning the repository.
- Finding out why
git applyorpatchsays “patch does not apply”. - Applying a small fix to a configuration file on a machine without git.
- Splitting a large patch so each part can be reviewed or applied on its own.
Reading a unified diff
--- a/fileand+++ b/filename the old and new file (/dev/nullfor a created or deleted file).@@ -12,7 +12,8 @@ function namestarts a hunk: 7 lines from line 12 of the old file become 8 lines from line 12 of the new file; the text after the second@@is the enclosing function, for orientation only.- Lines start with a space (unchanged context),
-(removed) or+(added).\ No newline at end of filesays the line before it has no line break. - git adds headers for new and deleted files, mode changes, renames and copies (
rename from,similarity index 90%) and binary changes.
The format is described in the GNU diffutils manual; e-mailed patches follow git format-patch.
Why a patch does not apply
- The file changed since the patch was made. Context lines or removed lines differ; the report shows the closest place and the first line that differs.
- Line endings. A patch saved with Windows line endings (CRLF), or a file with CRLF and a patch with LF, makes every line different to
git apply. Try Ignore whitespace, or convert the line endings. - Mangled whitespace. E-mail programs and editors strip trailing spaces, turn tabs into spaces, or drop the leading space of empty context lines (“corrupt patch at line …”). The page points these out.
- The wrong strip level or path.
git applyexpects paths witha/andb/; GNUpatchneeds-p1for them. - Already applied. The new lines are already there: the hunk is reported as applied before.
Limitations
- Binary changes (GIT binary patch) are listed but not shown or applied.
- Applying works on one file’s text at a time, or on several opened files; it does not merge three ways like
git apply --3way. - Files over 20 MB cannot be opened. Very large patches open with only the first files expanded; the others are drawn when you open them.
- Syntax colours cover common languages and are turned off when a file’s type is not recognised.
Privacy
Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.
Frequently asked questions
What do I get without a pass?
Without a pass, Git Patch and Diff Viewer (Apply, Reverse, Split) shows every count and file of the patch, the diffs of the first files under a MySmartCoPilot mark (up to 3) and the first lines of a patched file (up to 20). Until you unlock it, the result can’t be downloaded or copied. A Pro, Premium or Ultimate pass, a one-time payment that never renews, unlocks the full result. The pricing page lists the passes and their prices.
What is the difference between git apply, git am and patch?
git apply applies a diff to your working files. git am applies git format-patch e-mails as commits, keeping their author, date and message. GNU patch applies unified diffs without git and allows fuzz: a few context lines at the ends of a hunk may differ. This page applies like patch, with the same default fuzz of 2.
What do “offset” and “fuzz” mean?
An offset means the hunk was found a few lines away from where its header says, because the file gained or lost lines above it; that is safe. Fuzz means up to that many context lines at the ends of the hunk did not match and were ignored; check the result there, because the patch may have landed in a similar but wrong place.
What is a .rej file?
The hunks that could not be applied, written out so you can apply them by hand. GNU patch writes one next to the file; here it downloads after applying, with a pass.
Is the patch uploaded?
No. Patches, files and results are read and made by this page in your browser, and work offline once the page has loaded.
How do I make a patch?
git diff > change.patch for uncommitted changes, git format-patch -1 for the last commit, or diff -u old new > change.diff without git. To compare two texts here, use Text Diff.