Recently met git format-patch and git am circumstances does not work with git format-patch to play patch with git am not a direct hit, each time conflict, the cause has not been found, I had to find other ways, in the process found that can generate a patch with the diff command, hit the patch with the patch command.
1. Generate patches for a single file
1 $ diff -up linux-2.6.28.8/net/sunrpc/svc.orig.c linux-2.6.28.8/net/sunrpc/svc.c > patch
1 diff -up linux-2.6.28.8/net/sunrpc/svc.orig.c 2009-03-17 08:50:04.000000000 +0800 2 +++ linux-2.6.28.8/net/sunrpc/svc.c 2009-03-30 19:18:41.859375000 +0800 3 @@ -1050,11 +1050,11 @@ svc_process(struct svc_rqst *rqstp)
2. Generate patches for multiple files
1 $ diff -uprN linux-2.6.28.8.orig/net/sunrpc/ linux-2.6.28.8/net/sunrpc/ > patch
3. Patching
1 $ patch -p1 < patch1.diff
Example 4
1 $ diff -uprN linux-2.6.31.3 linux-2.6.31.3_1/ > mypatch 2 $ cd linux-2.6.31.3 3 $ patch -p1 < mypatch
Notes :
1. When playing patch, parameter -p1, is 1 instead of l. Why ignore the first-level directory, because the same tree structure under the project, but the project is not necessarily the same name, so playing patch when you can avoid this problem by p1. This particular execution path can be determined by looking at the patch of the patch content.
2. Parameter -p1 1 1 directory level representatives ignored, if the parameter is ignored -p2 directory level 2, and so on. Example 4 Take, for example, is directly behind the diff -upRn with two parts catalog file is modified, so playing patch parameters -p1 can. If the directory folder in front of two same path, then the parameters need to be changed -p3
Reference links: generating patch and hit the patch under Linux https://www.cnblogs.com/aaronLinux/p/5860552.html