grigoryvp
grigoryvp

Reputation: 42483

How to create a patch file on windows?

On windows, I have two source files and want to create a patch with difference, like this one. But I'm unsure, what format this patch is and what app to use in order to create it? GNU diff output is very different from the patch I can see in the link above.

Upvotes: 30

Views: 49595

Answers (8)

ClassY
ClassY

Reputation: 655

I've also made a tool to generate patch files (like WinMerge html format) between two sets of changesets/folders/commits (as a zip downloaded from github or azure or just folders sitting in your drive) since currently WinMerge does NOT support path file generation from command-line to support automation.

use it like:

python diff_generator.py --c1 "path_to_file1.zip" --c2 "path_to_file2.zip" [--git]

or

python diff_generator.py --c1 "path_to_folder1" --ddc1 --c2 "path_to_folder2" --ddc2

Upvotes: 0

Ian Brumby
Ian Brumby

Reputation: 111

In Beyond Compare 4 you can generate a unified diff by selecting the 'Session' > 'Text Compare Report...' menu item and then selecting 'Patch' for the layout and 'Unified diff' for the patch style. Then save the output to file, or to the clipboard.

Upvotes: 1

Dave Burton
Dave Burton

Reputation: 3040

Thanks, PhiLho & Lukáš! The diff program from UnxUtils works great under Windows 7 to generate the patch file:

diff -u oldfile newfile >patchfile

Likewise, the patch program from UnxUtils works great to apply the patch:

patch -u oldfile patchfile

Upvotes: 24

Pupil
Pupil

Reputation: 23958

WinMerge is the best tool for windows. To create a patch file, you need to do the following:

File>Open

-- Here you open the files for which you are generating patch file.

Tools>Generate Patch

-- Here you specify the path where to save the patch file. And WinMerge will save patch file for you.

Upvotes: 10

sha1
sha1

Reputation: 71

WinMerge (http://winmerge.org/) is what you need. You also can compare whole file trees with this tool, which is an absolute must-have for some people.

Upvotes: 7

PhiLho
PhiLho

Reputation: 41142

The UnxUtils package offers lot of useful Unix tools for Windows, with a minimal impact on Windows installation (unzip, add location to path, use it).
It has a diff.exe

Upvotes: 4

Aaron Digulla
Aaron Digulla

Reputation: 328604

Try WinMerge. You'll find a patch generator in the "Tools" menu.

Upvotes: 27

Lukáš Lalinský
Lukáš Lalinský

Reputation: 41306

The output format is called "unified diff", it can be generated using diff -u.

Upvotes: 17

Related Questions