/ Published in: Bash
- Although diff can output in diverse formats, the easiest to read is the unified format; simply use the -u switch to generate unified output.
- diff -u old.php new.php > file.patch
- Note: the symbol > will redirect the output to the file file.patch
- Because patch readability is important for the review process it's best to add another switch: -p. This switch shows the function closest to the difference, making it easy to see what function changed. (alternately you can use the flag -F^function or in abbreviated form -F^f)
- diff -up old.php new.php > file.patch
- When you've modified multiple files in the source tree, use diffs ability to compare directories. Add the -r switch to instruct diff to recurse (sub)directories and add the -N switch to account for new or deleted files:
- diff -urNp old_directory new_directory > file.patch
You need to login to post a comment.