Linux<\/a>Shell\u4e2d\u7684patch\u547d\u4ee4\u65f6\uff0c\u6709\u4e00\u4e9b\u6ce8\u610f\u4e8b\u9879\u987b\u8981\u6ce8\u610f\uff1a<\/p>\n\u786e\u4fdd\u8865\u4e01\u6587\u4ef6\u4e0e\u6e90\u4ee3\u7801\u6587\u4ef6\u5339\u914d\uff1a\u8865\u4e01\u6587\u4ef6\u662f\u6309\u7167\u6e90\u4ee3\u7801\u6587\u4ef6\u751f\u6210\u7684\uff0c\u56e0\u800c\u786e\u4fdd\u8865\u4e01\u6587\u4ef6\u4e0e\u8981\u5e94\u7528\u7684\u6e90\u4ee3\u7801\u6587\u4ef6\u662f\u5339\u914d\u7684\u3002\u5047\u5982\u8865\u4e01\u6587\u4ef6\u4e0e\u6e90\u4ee3\u7801\u6587\u4ef6\u4e0d\u5339\u914d\uff0c\u5c06\u4f1a\u51fa\u73b0\u9519\u8bef\u3002<\/p>\n
\u4f7f\u7528\u6b63\u786e\u7684\u5265\u79bb\u8def\u5f84\u7ea7\u522b\uff1a\u5047\u5982\u8865\u4e01\u6587\u4ef6\u4e2d\u7684\u8def\u5f84\u4e0e\u5f53\u524d\u76ee\u5f55\u4e0b\u7684\u6e90\u4ee3\u7801\u6587\u4ef6\u8def\u5f84\u4e0d\u5339\u914d\uff0c\u987b\u8981\u4f7f\u7528-p\u9009\u9879\u6765\u6307\u5b9a\u5265\u79bb\u8def\u5f84\u7684\u7ea7\u522b\u3002\u5265\u79bb\u8def\u5f84\u7ea7\u522b\u8868\u793a\u4ece\u8865\u4e01\u6587\u4ef6\u4e2d\u5265\u79bb\u7684\u8def\u5f84\u5c42\u7ea7\u6570\u3002\u8bf8\u5982\uff0c\u5047\u5982\u8865\u4e01\u6587\u4ef6\u4e2d\u7684\u8def\u5f84\u662fa\/b\/c\/file.txt\uff0c\u800c\u6e90\u4ee3\u7801\u6587\u4ef6\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\uff0c\u5219\u987b\u8981\u4f7f\u7528-p2\u9009\u9879\u6765\u5265\u79bb\u4e24\u7ea7\u8def\u5f84\u3002<\/p>\n
<\/p>\n
\u6ce8\u610f\u64a4\u6d88\u5df2\u5e94\u7528\u7684\u8865\u4e01\uff1a\u4f7f\u7528-R\u9009\u9879\u53ef\u4ee5\u64a4\u6d88\u65e9\u5df2\u5e94\u7528\u7684\u8865\u4e01\u3002\u5728\u64a4\u6d88\u8865\u4e01\u65f6\uff0c\u987b\u8981\u786e\u4fdd\u8865\u4e01\u6587\u4ef6\u4e0e\u5df2\u5e94\u7528\u7684\u8865\u4e01\u5b8c\u5168\u5339\u914d\u3002<\/p>\n
\u4f7f\u7528\u5b89\u9759\u6a21\u5f0f\uff1a\u4f7f\u7528-s\u9009\u9879\u53ef\u4ee5\u6b65\u5165\u5b89\u9759\u6a21\u5f0f\uff0c\u4e0d\u663e\u793a\u8be6\u5c3d\u7684\u8f93\u51fa\u4fe1\u606f\u3002\u8fd9\u5728\u6279\u91cf\u5e94\u7528\u8865\u4e01\u65f6\u53ef\u4ee5\u964d\u4f4e\u8f93\u51fa\u4fe1\u606f\u7684\u5e72\u6270\u3002<\/p>\n
\u51c6\u8bb8\u6dfb\u52a0\u65b0\u6587\u4ef6\uff1a\u4f7f\u7528-N\u9009\u9879\u53ef\u4ee5\u5bb9\u8bb8\u6dfb\u52a0\u65b0\u6587\u4ef6\u3002\u6709\u65f6\u4faf\uff0c\u8865\u4e01\u6587\u4ef6\u53ef\u80fd\u5305\u542b\u65b0\u7684\u6587\u4ef6\uff0c\u4f7f\u7528\u8be5\u9009\u9879\u53ef\u4ee5\u5bb9\u8bb8\u6dfb\u52a0\u8fd9\u79cd\u65b0\u6587\u4ef6\u3002<\/p>\n
\u6ce8\u610f\u8865\u4e01\u6587\u4ef6\u7684\u683c\u5f0f\uff1a\u8865\u4e01\u6587\u4ef6\u5e94\u5f53\u4f9d\u7167\u7279\u5b9a\u7684\u683c\u5f0f\u8fdb\u884c\u7f16\u64b0\uff0c\u5305\u542b\u5fc5\u8981\u7684\u884c\u4fe1\u606f\u3002\u5047\u5982\u8865\u4e01\u6587\u4ef6\u7684\u683c\u5f0f\u4e0d\u6b63\u786e\uff0c\u6bd4\u5982\u7f3a\u4e4f\u5fc5\u8981\u7684\u884c\u4fe1\u606f\uff0c\u5c06\u4f1a\u51fa\u73b0\u9519\u8bef\u3002<\/p>\n
\u5e95\u5c42\u5b9e\u73b0<\/p>\n
LinuxShell\u4e2d\u7684patch\u547d\u4ee4\u5e95\u5c42\u5b9e\u73b0\u4e3b\u8981\u662f\u901a\u8fc7diff\u548cpatch\u5de5\u5177\u6765\u5b8c\u6210\u3002<\/p>\n
diff\u5de5\u5177\uff1adiff\u5de5\u5177\u7528\u4e8e\u6bd4\u8f83\u4e24\u4e2a\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u5dee\u522b\uff0c\u5e76\u751f\u6210\u8865\u4e01\u6587\u4ef6\u3002\u901a\u8fc7\u6bd4\u8f83\u6e90\u6587\u4ef6\u548c\u76ee\u6807\u6587\u4ef6\u7684\u5185\u5bb9\uff0cdiff\u5de5\u5177\u4f1a\u751f\u6210\u4e00\u7cfb\u5217\u63cf\u8ff0\u5dee\u522b\u7684\u884c\u3002\u90a3\u4e9b\u884c\u5305\u542b\u4e86\u8981\u6dfb\u52a0\u3001\u5220\u9664\u6216\u66f4\u6539\u7684\u5185\u5bb9\u3002diff\u5de5\u5177\u652f\u6301\u591a\u79cd\u683c\u5f0f\u7684\u8865\u4e01\u6587\u4ef6\u751f\u6210\uff0c\u6bd4\u5982\u666e\u901a\u683c\u5f0f\u3001\u4e0a\u4e0b\u6587\u683c\u5f0f\u548c\u7edf\u4e00\u683c\u5f0f\u3002<\/p>\n
patch\u5de5\u5177\uff1apatch\u5de5\u5177\u7528\u4e8e\u6309\u7167\u8865\u4e01\u6587\u4ef6\u6765\u5e94\u7528\u8865\u4e01\u3002\u5b83\u4f1a\u8bfb\u53d6\u8865\u4e01\u6587\u4ef6\u4e2d\u7684\u63cf\u8ff0\u5dee\u522b\u7684\u884c\uff0c\u5e76\u6309\u7167\u8fd9\u79cd\u884c\u6765\u66f4\u6539\u6e90\u6587\u4ef6\u3002patch\u5de5\u5177\u4f1a\u4f9d\u7167\u8865\u4e01\u6587\u4ef6\u4e2d\u7684\u8def\u5f84\u4fe1\u606f\u548c\u66f4\u6539\u64cd\u4f5c\u6765\u5b9a\u4f4d\u6e90\u6587\u4ef6\uff0c\u5e76\u5c06\u66f4\u6539\u5e94\u7528\u5230\u76f8\u5e94\u7684\u4f4d\u7f6e\u3002\u5f53\u5e94\u7528\u8865\u4e01\u65f6\uff0cpatch\u5de5\u5177\u4f1a\u68c0\u6d4b\u6e90\u6587\u4ef6\u7684\u5185\u5bb9\u548c\u8865\u4e01\u6587\u4ef6\u4e2d\u63cf\u8ff0\u7684\u5dee\u522b\u662f\u5426\u5339\u914d\uff0c\u5047\u5982\u5339\u914d\u5219\u5e94\u7528\u8865\u4e01\uff0c\u5426\u5219\u4f1a\u62a5\u9519\u3002<\/p>\n
\u5728\u5e95\u5c42\u5b9e\u73b0\u4e2d\uff0cpatch\u547d\u4ee4\u4f1a\u8c03\u7528diff\u5de5\u5177\u751f\u6210\u8865\u4e01\u6587\u4ef6\uff0c\u5e76\u4f7f\u7528patch\u5de5\u5177\u6765\u5e94\u7528\u8865\u4e01\u6587\u4ef6\u3002patch\u547d\u4ee4\u4f1a\u89e3\u6790\u7528\u6237\u63d0\u4f9b\u7684\u9009\u9879\u548c\u53c2\u6570\uff0c\u5e76\u5c06\u5176\u4f20\u9012\u7ed9diff\u548cpatch\u5de5\u5177\u8fdb\u884c\u76f8\u5e94\u7684\u64cd\u4f5c\u3002\u901a\u8fc7\u8fd9\u4e9b\u65b9\u6cd5\uff0cpatch\u547d\u4ee4\u5b9e\u73b0\u4e86\u5bf9\u6e90\u6587\u4ef6\u7684\u66f4\u6539\u548c\u66f4\u65b0\u3002<\/p>\n
\u987b\u8981\u6ce8\u610f\u7684\u662f\uff0cpatch\u547d\u4ee4\u5e95\u5c42\u5b9e\u73b0\u53ef\u80fd\u4f1a\u56e0\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\u6216\u53d1\u884c\u7248\u800c\u6709\u6240\u5dee\u522blinux\u64cd\u4f5c\u7cfb\u7edf\u7248\u672c\uff0c\u4f46\u57fa\u672c\u539f\u7406\u548c\u4f7f\u7528\u65b9\u5f0f\u662f\u76f8\u50cf\u7684\u3002<\/p>\n
\u521b\u5efa\u8865\u4e01<\/p>\n
\u521b\u5efa\u8865\u4e01\u6700\u7b80\u5355\u7684\u529e\u6cd5\u662f\u901a\u8fc7\u4e24\u4efd\u4ee3\u7801\u8fdb\u884c\uff0c\u4e00\u4efd\u6e90\u7801\uff0c\u53e6\u4e00\u4efd\u662f\u52a0\u8fdb\u4e86\u6240\u66f4\u6539\u90e8\u4efd\u7684\u6e90\u4ee3\u7801\u3002\u539f\u5148\u7684\u53d6\u540dlinux-x.y.z\uff0c\u800c\u66f4\u6539\u8fc7\u7684\u5c31\u53d6\u540d\u4e3alinux\u3002\u4e4b\u540e\u501f\u52a9\u4e0b\u8fb9\u7684\u547d\u4ee4\u901a\u8fc7\u8fd9\u4e24\u4efd\u4ee3\u7801\u521b\u5efa\u8865\u4e01:<\/p>\n
diff-urNlinux-x.y.z\/linux\/>my-patch<\/p>\n
\u901a\u8fc7-u\u53c2\u6570\u6307\u5b9a\u4f7f\u7528\u7279\u6b8a\u7684dif\u8f93\u51fa\u683c\u5f0f\u3002\u5426\u5219\u5f97\u5230\u7684patch\u683c\u5f0f\u5947\u7279\uff0c\u901a\u5e38\u4eba\u90fd\u96be\u4ee5\u8bfb\u61c2\u3002<\/p>\n
-r\u53c2\u6570\u4fdd\u8bc1\u4f1a\u5386\u6240\u6709\u5b50\u76ee\u5f55\u8fdb\u884c\u64cd\u4f5c\u3002<\/p>\n
-N\u53c2\u6570\u6307\u660e\u4f5c\u51fa\u66f4\u6539\u7684\u6e90\u4ee3\u7801\u4e2d\u6240\u6709\u65b0\u52a0\u7684\u6587\u4ef6\u5728dif\u4f5c\u65f6\u4f1a\u542b\u5728\u3002\u53e6\u5916\uff0c<\/p>\n
\u5982\u60f3\u5bf9\u4e00\u4e2a\u5355\u72ec\u7684\u6587\u4ef6\u8fdb\u884cdif\uff0c\u4f60\u4e5f\u53ef\u4ee5\u5982\u6b64\u505a:<\/p>\n
diff-ulinux-x.y.z\/some\/flelinux\/some\/file>my-patch<\/p>\n
<\/p>\n
\u6ce8\u610f\uff0c\u5728\u4f60\u81ea\u5df1\u4ee3\u7801\u6240\u5728\u7684\u76ee\u5f55\u4e0b\u6267\u884cdiff\u5f88\u91cd\u8981\u3002\u8fd9\u6837\u521b\u5efa\u7684\u8865\u4e01\u4ed6\u4eba\u7528\u4e0a\u53bb\u66f4\u4fbf\u6377\uff0c\u54ea\u6015\u5979\u4eec\u7684\u76ee\u5f55\u540d\u5b50\u53ebdifer\u4e5f\u6ca1\u95ee\u9898\u3002\u6267\u884c\u4e00\u4e2a\u8fd9\u6837\u751f\u6210\u7684\u8865\u4e01\uff0c\u53ea\u987b\u8981\u5728\u4f60\u81ea\u5df1\u4ee3\u7801\u6811\u7684\u6839\u76ee\u5f55\u6267\u884c\u4e0b\u8ff0\u547d\u4ee4\u5c31\u53ef\u4ee5\u4e86:<\/p>\n
patch-pl<...\/my-patch<\/p>\n
\u5728\u8fd9\u4e2a\u53cd\u4f8b\u4e2d\uff0c\u8865\u4e01\u7684\u540d\u5b50\u53ebmy-patchlinux\u684c\u9762\uff0c\u5b83\u5750\u843d\u5f53\u524d\u76ee\u5f55\u7684\u4e0a\u4e00\u7ea7\u76ee\u5f55\u4e2d\u3002-p1\u53c2\u6570\u62ff\u6765\u526a\u9664\u8865\u4e01\u4e2d\u5934\u4e00\u4e2a\u76ee\u5f55\u7684\u540d\u79f0\u3002\u5982\u6b64\u505a\u7684\u7528\u5904\u662f\u53ef\u4ee5\u5728\u6253\u8865\u4e01\u7684\u65f6\u4faf\u5ffd\u89c6\u521b\u5efa\u8865\u4e01\u7684\u4eba\u7684\u76ee\u5f55\u547d\u540d\u4e60\u60ef\u3002<\/p>\n
diffstat\u662f\u4e00\u4e2a\u5f88\u6709\u7528\u7684\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u5217\u4e3e\u8865\u4e01\u6240\u9020\u6210\u7684\u53d8\u66f4\u7684\u7edf\u8ba1(\u52a0\u5165\u6216\u79fb\u53bb\u7684\u4ee3\u7801\u884c)\u3002\u8f93\u51fa\u5173\u4e8e\u8865\u4e01\u7684\u4fe1\u606f\uff0c\u6267\u884c:<\/p>\n
diffstat-plmy-patch<\/p>\n
\u5728\u8d34\u51fa\u81ea\u5df1\u7684\u8865\u4e01\u65f6\uff0c\u9644\u9001\u4e0a\u8fd9\u4efd\u4fe1\u606f\u5e38\u5e38\u4f1a\u5f88\u6709\u7528\u3002\u56e0\u4e3apatch(1)\u4f1a\u5ffd\u89c6\u7b2c\u4e00\u4e2adiff\u4e4b\u524d\u7684\u6240\u6709\u5185\u5bb9\uff0c\u6240\u4ee5\u4f60\u751a\u81f3\u53ef\u4ee5\u5728patch\u7684\u6700\u4e0a\u9762\u76f4\u63a5\u52a0\u4e0a\u7b80\u7565\u7684\u8bf4\u660e\u3002<\/p>\n
\u7528Git\u521b\u5efa\u8865\u4e01<\/p>\n
\u5047\u5982\u4f60\u7528Git\u7ba1\u6e90\u4ee3\u7801\uff0c\u987b\u8981\u4f7f\u7528Git\u521b\u5efa\u8865\u4e01\u3002\u7528Git\u521b\u5efa\u8865\u5e76\u4e0d\u662f\u54ea\u4e9b\u96be\u4e8b\uff0c\u53ea\u987b\u8981\u4e24\u4e2a\u8fc7\u7a0b\u3002\u9996\u5148\uff0c\u4f60\u5fc5\u987b\u662f\u66f4\u6539\u8005\uff0c\u4e4b\u540e\u5728\u672c\u5730\u9012\u4ea4\u4f60\u7684\u66f4\u6539\u3002\u628a\u66f4\u6539\u9012\u4ea4\u5230Git\u6811\u4e0e\u9012\u4ea4\u5230\u6807\u51c6\u7684\u6e90\u4ee3\u7801\u6811\u5e76\u6ca1\u6709\u54ea\u4e9b\u4e24\u6837\u3002\u4f60\u6839\u672c\u4e0d\u987b\u8981\u4e13\u95e8\u505a\u4efb\u4f55\u4e8b\u60c5\u53bb\u7f16\u8f91\u50a8\u5b58\u5728Git\u4e2d\u7684\u6587\u4ef6\u3002\u4f60\u4f5c\u51fa\u66f4\u6539\u540elinux \u5e94\u7528patch<\/strong>\uff0c\u5c31\u987b\u8981\u628a\u6240\u505a\u7684\u66f4\u6539\u9012\u4ea4\u5230\u4f60\u7684Git\u7248\u5e93:<\/p>\ngitcommit-a<\/p>\n
-a\u6570\u8868\u793a\u9012\u4ea4\u6240\u6709\u7684\u66f4\u6539\u3002\u5047\u5982\u4f60\u4ec5\u4ec5\u60f3\u9012\u4ea4\u67d0\u4e2a\u6307\u5b9a\u6587\u4ef6\u7684\u66f4\u6539\uff0c\u5219\u5982\u4e0b\u793a\u4f8b:<\/p>\n
gitcommitsome\/file.c<\/p>\n
\u7136\u800c\u867d\u7136\u6709\u4e86-a\u53c2\u6570\uff0cGit\u5e76\u4e0d\u7acb\u523b\u9012\u4ea4\u65b0\u6587\u4ef6\uff0c\u76f4\u81f3\u628a\u5b83\u4eec\u6dfb\u52a0\u5230\u7248\u672c\u5e93\u4e2d\u624d\u9012\u4ea4\u3002\u8981\u964d\u4f4e\u4e00\u4e2a\u6587\u4ef6\uff0c\u4e4b\u540e\u518d\u9012\u4ea4\uff0c\u5219\u8f93\u5165\u5982\u4e0b\u4e24\u6761\u547d\u4ee4:<\/p>\n
gitaddsome\/other\/file.c<\/p>\n
gitcommit-a<\/p>\n
\u5f53\u6267\u884cGit\u7684commit\u547d\u4ee4\u65f6,Git\u4f1a\u8981\u6c42\u8f93\u5165\u4e00\u4e2a\u4fee\u6539\u65e5\u5fd7\u3002\u4f60\u5e94\u5f53\u5c3d\u91cf\u586b\u5199\u7684\u8be6\u5c3d\u548c\u5b8c\u6574\u6e05\u695a\u5730\u89e3\u91ca\u66f4\u6539\u539f\u56e0\u3002\u5f53\u5728\u6e90\u7801\u6811\u4e2d\u6709\u4e00\u4e2a(\u6216\u4e24\u4e2a)\u9012\u4ea4\u65f6\uff0c\u53ef\u4ee5\u4e3a\u6bcf\u4f4d\u9012\u4ea4\u521b\u5efa\u4e00\u4e2a\u8865\u4e01\uff0c\u53ef\u4ee5\u50cf\u524d\u9762\u7ae0\u8282\u6240\u63cf\u8ff0\u7684\u90a3\u6837\u6765\u5904\u7406\u8fd9\u4e2a\u8865\u4e01:<\/p>\n
gitformat-patchorigin<\/p>\n
\u5bf9\u4e8e\u6240\u6709\u7684\u9012\u4ea4\uff0c\u8fd9\u6837\u5f62\u6210\u7684\u8865\u4e01\u653e\u5230\u4f60\u7684\u7248\u672c\u5e93\u4e2d\u800c\u4e0d\u662f\u539f\u59cb\u6811\u4e2d\u3002Git\u5f62\u6210\u7684\u8865\u4e01\u5750\u843d\u6e90\u4ee3\u7801\u6811\u7684\u6839\u76ee\u5f55\u4e2d\u3002\u82e5\u679c\u53ea\u60f3\u4e3a\u6700\u540e\u7b2cN\u6b21\u9012\u4ea4\u5f62\u6210\u8865\u4e01\uff0c\u5219\u53ef\u4ee5\u6267\u884c\u4e0b\u8ff0\u547d\u4ee4:<\/p>\n
gitformat-patch-N<\/p>\n
\u6bd4\u5982\uff0c\u4e0b\u8fb9\u7684\u547d\u4ee4\u53ea\u4e3a\u6700\u540e\u4e00\u6b21\u9012\u4ea4\u5f62\u6210\u4e00\u4e2a\u8865\u4e01:<\/p>\n
gitformat-patch-1<\/p>\n","protected":false},"excerpt":{"rendered":"
\u5e94\u7528\u8865\u4e01\u6587\u4ef6\uff1a\u8be5\u547d\u4ee4\u5c06\u8865\u4e01\u6587\u4ef6patchfile\u5e94\u7528\u5230\u5f53\u524d\u76ee\u5f55\u4e0b\u7684\u6e90\u4ee3\u7801\u6587\u4ef6\u4e2d\u3002\u8be5\u547d\u4ee4\u5c06\u8865\u4e01\u6587\u4ef6patchfile\u5e94\u7528\u5230\/path\/to\/directory\u76ee\u5f55\u4e0b\u7684\u6e90\u4ee3\u7801\u6587\u4ef6\u4e2d\u3002patch\u5de5\u5177\uff1apatch\u5de5\u5177\u7528\u4e8e\u6839\u636e\u8865\u4e01\u6587\u4ef6\u6765\u5e94\u7528\u8865\u4e01\u3002<\/p>\n","protected":false},"author":1,"featured_media":294574,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[4463,4465,4464,1642,1850],"class_list":["post-294573","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-pml-3","tag-xgydm","tag-yybdwj","tag-yf","tag-xx-2"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/294573","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=294573"}],"version-history":[{"count":0,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/294573\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/294574"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=294573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=294573"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=294573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}