Archive for December, 2009

How to read a patch or diff and understand its structure to apply it manually

December 5th, 2009

Hi :)

I wrote this article to show you how patch/diff files store difference information. After reading it you will be able to understand patch files when you read them, better understand certain patch error messages and apply changes manually.

Patch or diff files are just text files, so you can look at them with less or a text editor.

If you prefer to use a terminal, colordiff (in the colordiff package) provides syntax highlighting. If the patch is long, you may want to use less to look at it. You need the -R option for less, or else the colors won’t show. I also always use -S, which will enable horizontal scrolling in less instead of wrapping long lines. The whole command to view a patch with syntax highlighting through less in a terminal is:

markus@ubuntu:~$ cat file.patch | colordiff | less -RS
Patch formats

» Read more: How to read a patch or diff and understand its structure to apply it manually

© 2017 Markus Bertheau. All rights reserved.