Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between patch and diff files

Tags:

git

linux

svn

Could somebody explain me the difference between a .diff file and .patch file.

like image 880
Navaneeth Sen Avatar asked Nov 18 '10 14:11

Navaneeth Sen


People also ask

How does patch and diff work?

diff works by cataloging the changes between the two files or folders. Patch can take those changes, put them in a file, and update older versions with it.

What is a diff file?

A DIFF file is a single file showing the differences between one or more text or source files. It is created by Mercurial, a control management tool for developers to obtain differences between files and apply the patches.

What is the difference between a patch and a duff file?

There are no differences.

What is patch file?

The patch file (also called a patch for short) is a text file that consists of a list of differences and is produced by running the related diff program with the original and updated file as arguments. Updating files with patch is often referred to as applying the patch or simply patching the files.


2 Answers

What matters is the content of the file, not the extension. Both of those extensions imply that some sort of diff utility (diff, git diff, git format-patch, svn diff) produced the output.

Many diff utilities produce output which can be applied by the patch command. You will frequently need to use the -d and -p options to patch in order to get the paths matched up right (strip prefix, name target directory). If you see one of those extensions on a file distributed online, it's almost certainly an indication it's compatible with patch.

Git's diff output is compatible with patch, but I believe svn's is not. Of course, plain patches generated by git diff are probably best applied by git apply, and patches generated by git format-patch are designed for use with git-am.

like image 84
Cascabel Avatar answered Sep 20 '22 19:09

Cascabel


There are no differences. diff utility produces a patch file which is applied using patch.

like image 33
khachik Avatar answered Sep 21 '22 19:09

khachik