I use these tools every once-in-a-while, which puts them in the category of "I know what they do and kind of how to use them, but I always have to spend time reading the man pages and searching the Internet for usage instructions".* So, here are instructions for me.
Here's my situation. I have a codebase on my localhost. I have a copy of that codebase that I edited while at a client. I need to merge the two codebases. The general idea is that I need to create a patch file by diff'ing the two codebases and apply it to my localhost codebase. This should be straightforward...
Creating the patch File Using diff
First, I think it's easiest (maybe necessary) to have the directories that one is diff'ing to live next to each other. E.g. /home/bob/work/trunk and /home/bob/work/branch.
Run this from the dir containing the old and new (trunk and branch) dirs.
$ diff -urwBN old new >patchfile
-u unified output (I've found this works best
-r recursive
-w ignore whitespace
-B ignore blank lines
-N treat blank files as new (otherwise new files will not be added)
Applying the Patchfile
$ cd old $ patch -p1 <../patchfile
* Please note, I know that a punctuation should live inside the quotes, but as a programmer, I don't like to do it that way.
- ian's blog
- Login or register to post comments