Try WinMerge. You'll find a patch generator in the "Tools" menu. The diff program from UnxUtils works great under Windows 7 to generate the patch file:. WinMerge is the best tool for windows. To create a patch file, you need to do the following:. And WinMerge will save patch file for you. You also can compare whole file trees with this tool, which is an absolute must-have for some people.
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. Then save the output to file, or to the clipboard.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to create a patch file on windows? Ask Question. Asked 12 years, 2 months ago. Active 1 year ago.
That is, when patching a file, rename or copy the original instead of removing it. When backing up a file that does not exist, an empty, unreadable backup file is created as a placeholder to represent the nonexistent file. See the -V or --version-control option for details about how backup file names are determined. On systems like DOS where this option makes a difference, the patch should be generated by diff -a --binary. Normally this option is unnecessary, since patch can examine the time stamps on the header to determine whether a file should exist after patching.
However, if the input is not a context diff or if patch is conforming to POSIX , patch does not remove empty patched files unless this option is given. When patch removes a file, it also attempts to remove any empty ancestor directories.
Skip patches whose headers do not say which file is to be patched; patch files even though they have the wrong version for the Prereq: line in the patch; and assume that patches are not reversed even if they look like they are. This option does not suppress commentary; use -s for that. This option only applies to diffs that have context, and causes patch to ignore up to that many lines in looking for places to install a hunk.
Note that a larger fuzz factor increases the odds of a faulty patch. The default fuzz factor is 2, and it may not be set to more than the number of lines of context in the context diff, ordinarily 3. If num is positive, patch gets or checks out the file from the revision control system; if zero, patch ignores RCS , ClearCase, and SCCS and does not get the file; and if negative, patch asks the user whether to get the file. If patchfile is - , read from standard input, the default. Any sequence of one or more blanks in the patch file matches any sequence in the original file, and sequences of blanks at the ends of lines are ignored.
Normal characters must still match exactly. Each line of the context must still match a line in the original file. See also -R. A sequence of one or more adjacent slashes is counted as a single slash. This controls how file names found in the patch file are treated, in case you keep your files in a different directory than the person who sent out the patch.
Whatever you end up with is looked for either in the current directory, or the directory specified by the -d option. Tag Description o Take the first existing file from the list old, new, index when intuiting file names from diff headers.
The word should be one of the following: Tag Description literal Output names as-is. If that environment variable is not set, the default value is shell. Rejects come out in the swapped format. The -R option does not work with ed diff scripts because there is too little information to reconstruct the reverse operation.
If the first hunk of a patch fails, patch reverses the hunk to see if it can be applied that way. If it can, you are asked if you want to have the -R option set. Note: this method cannot detect a reversed patch if it is a normal diff and if the first command is an append i. Luckily, most patches add or change lines rather than delete them, so most reversed normal diffs begin with a delete, which fails, triggering the heuristic.
This option is not recommended, because patches using local time cannot easily be used by people in other time zones, and because local time stamps are ambiguous when local clocks move backwards during daylight-saving time adjustments.
Instead of using this option, generate patches with UTC and use the -Z or --set-utc option instead. The method does not affect whether backup files are made; it affects only the names of any backup files that are made. The valid values for method are unique abbreviations are accepted : Tag Description existing or nil Make numbered backups of files that already have them, otherwise simple backups.
This is the default. The numbered backup file name for F is F. The -B or --prefix , -Y or --basename-prefix , and -z or --suffix options specify the simple backup file name.
For example, with -Y. Also see the -T or --set-time option. However, if the -f or --force option is given, the file time is set regardless. Due to the limitations of diff output format, these options cannot update the times of files whose contents have not changed. Also, if you use these options, you should remove e. Create your patch systematically. A good method is the command diff -Naur old new where old and new identify the old and new directories.
The names old and new should not contain any slashes. The option string -Np1 is recommended. Test your procedure by pretending to be a recipient and applying your patch to a copy of the original files. You can save people a lot of grief by keeping a patchlevel. By following those instructions, the changes in the modified file are replicated in the original file.
Now imagine that process happening to an entire directory of text files. All in one go. All you get sent is the patch file. Why send dozens of files round when you can send one file, or post one file for easy download? What do you do with the patch file to actually patch your files?
The patch command is most often used by people working with software source code files, but it works equally well with any set of text files whatever their purpose, source code or not. In this scenario, we are in a directory called work which contains two other directories. One is called working, and the other one is called latest. The working directory holds a set of source code files. The latest directory holds the most recent version of those source code files, some of which have been modified.
To be safe, the working directory is a copy of the current version of the text files. The diff command finds the differences between two files. Its default action is to list the modified lines in the terminal window. One file is called slang. The -u unified option tells diff to also list some of the un-modified text lines from before and after each of the changed sections. These lines are called context lines.
They help the patch command locate precisely where a change must be made in the original file. We provide the names of the files so that diff knows which files to compare. The original file is listed first, then the modified file. This is the command we issue to diff :. If the files were identical, there would be no output listed at all.
Seeing this type of output from diff confirms that there are differences between the two file versions and that the original file needs patching. To capture those differences in a patch file, use the following command.
The name of the patch file is arbitrary. You can call it anything you like. The -u unified option lets patch know that the patch file contains unified context lines. In other words, we used the -u option with diff, so we use the -u option with patch. We can instruct patch to make a backup copy of patched files before they are changed by using the -b backup option. The -i input option tells patch the name of the patch file to use:.
The file is patched as before, with no visible difference in the output. The date and time stamps of the files show that slang. We can use diff to create a patch file that contains all of the differences between the files in two directories.
We can then use that patch file with patch to have those differences applied to the files in the working folder with a single command. The -N option tells diff how to handle files in the latest directory that are not in the working directory.
It forces diff to put instructions in the patch file so that patch creates files that are present in the latest directory but missing from the working directory.
0コメント