2016年4月5日 星期二

Linux diff 和 patch 命令

1. Create a patch
$ diff -urN a/trunk b/trunk > c.patch

-a --text Treat all files as text.
-u -U NUM --unified[=NUM] Output NUM (default 3) lines of unified context.
-r --recursive Recursively compare any subdirectories found.
-N --new-file Treat absent files as empty.
2. Apply patch
$ patch -p1 < c.patch

-p0,Do not get rid of any level
-p1,Get rid of first level
-p2,Get rid of secondary level
-p NUM --strip=NUM Strip NUM leading components from file names.
-R --reverse Assume patches were created with old and new files swapped.
3. Restore the patch file
$ patch -R -p1 < c.patch

沒有留言:

張貼留言