Convert unified diff format output to standard .patch files, supporting both forward and reverse patch generation. Parses git diff output, counts changed lines โ a practical tool for code review and version control.
โข Patch Generation: Convert diff output to standard .patch format
โข Reverse Patch: Generate patches that undo changes
โข Change Statistics: Count added/removed/modified lines
โข Format Validation: Check diff format correctness
โข One-click Download: Download .patch files directly
Step 1: Paste git diff or diff -u output into the input area. Click "Load Example" to try it out.
Step 2: Set the Strip level (default 1, corresponding to patch -p1), then click "Generate Patch" or "Generate Reverse Patch".
Step 3: Copy or download the .patch file, then apply it in the terminal with patch -p1 < changes.patch.
Code Review: When reviewing others' changes, convert diff to patch, apply locally, and test to verify the changes meet expectations.
Version Rollback: Use reverse patches to quickly undo a commit's changes without manually reverting line by line โ ideal for emergency fixes.
Offline Distribution: In environments without direct Git access, distribute code changes via .patch files that recipients apply with the patch command.
Patch Format Standard: A standard .patch file contains: file headers (---old / +++new), change ranges (@@start,count+start,count@@), and diff lines (+added, -removed, space context). The patch command applies changes file by file, section by section.
Git Format-Patch: Patches generated by git format-patch include email headers (From, Subject, Date) and Git commit info, suitable for submitting code via email (like the Linux kernel workflow). This tool handles pure diff format without email headers.
A Patch file is a text file containing code difference information used to apply modifications to source files. The standard format includes file headers, change ranges, and specific diff lines. Can be applied automatically with the patch command.
Unified Diff is the most common diff format, generated by diff -u. It includes filenames, timestamps, change positions, and content differences. git diff outputs this format by default.
Use patch -p1 < changes.patch in the terminal. -p1 strips the first directory level from paths. Use --dry-run to preview without making actual changes.
Yes. git diff output is essentially unified diff format. The tool correctly parses extra git headers and generates standard .patch files.
There's no essential difference. By convention, .diff files are pure diff output, while .patch files are directly applicable with the patch command.
Yes. Use patch -R < changes.patch to reverse-apply a patch, effectively undoing the changes. You can also use this tool to generate a reverse patch.