diff, patch, diff3

In order to produce a patch file, I've looked through the following books:

In order to produce a patch, the first book suggests:

diff -Naur gcc-3.0.3 gcc-3.0.4

And the second book suggests:

LC_ALL=C TZ=UTC0 diff -rc2P gcc-2.3.2 gcc-2.3.3 | \
gzip -9 >gcc-2.3.2-2.3.3.patch.gz

I decided to follow the first variant:

diff -Naur old-version-dir new-version-dir > program.patch

(7 April, update) improved:

diff -Naur  --exclude=.svn --exclude='*~' --exclude='svn-commit.tmp' old-version-dir new-version-dir > program.patch

Applying a patch

If a patch is produced as above, the simplest way to apply the patch is:

$ cd program-directry
$ patch -p1 < path-to-patch-file

Using diff3

  • We had a file oldfile
  • You've made some changes to this file (let's name the result yourfile)
  • I also have made some changes to this file (let's name the result myfile)

The program diff3 can merge my and yuor changes:

diff3 -m myfile oldfile yourfile > newfile
Categories:

Updated: