{"id":37543,"date":"2023-01-06T18:27:34","date_gmt":"2023-08-02T07:50:33","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/git%e6%80%bb%e7%bb%93-3\/"},"modified":"2024-04-29T08:48:23","modified_gmt":"2024-04-29T00:48:23","slug":"git%e6%80%bb%e7%bb%93-3","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/git%e6%80%bb%e7%bb%93-3\/","title":{"rendered":"Git\u603b\u7ed3"},"content":{"rendered":"<h2>\u9996\u5148<\/h2>\n<p>\u9019\u7bc7\u6587\u7ae0\u91dd\u5c0d\u5c0d\u65bc\u57fa\u672c\u7684Git\u6307\u4ee4\uff0c\u50cf\u662fgit add\u3001git commit\u3001git push\uff0c\u6211\u5011\u53ef\u80fd\u90fd\u6709\u4e00\u5b9a\u7684\u7406\u89e3\uff0c\u4f46\u5be6\u969b\u4e0aGit\u505a\u4e86\u4ec0\u9ebc\u4e8b\u60c5\uff0c\u9019\u53ef\u80fd\u6703\u5f15\u8d77\u67d0\u4e9b\u4eba\u7684\u597d\u5947\u5fc3\u3002\u9019\u7bc7\u6587\u7ae0\u4ee5\u5be6\u7528Git\u70ba\u4e3b\u8981\u5167\u5bb9\uff0c\u53c3\u8003\u4e86Git\u7684\u5b98\u65b9\u6587\u4ef6\u7b49\u4f86\u89e3\u91cbGit\u662f\u4ec0\u9ebc\u3002\u540c\u6642\u4e5f\u5c07\u9019\u7bc7\u6587\u7ae0\u8996\u70ba\u5b78\u7fd2\u7684\u4e00\u90e8\u5206\u4f86\u5beb\u4f5c\uff0c\u6240\u4ee5\u5982\u679c\u6709\u4efb\u4f55\u932f\u8aa4\uff0c\u8acb\u5728\u8a55\u8ad6\u6216\u5176\u4ed6\u65b9\u5f0f\u4e2d\u8b93\u6211\u77e5\u9053\uff0c\u6211\u5c07\u4e0d\u52dd\u611f\u6fc0\u3002<\/p>\n<h2>Git\u7684\u57fa\u672c\u6982\u5ff5<\/h2>\n<p>\u30fb\u4ee3\u7801\u5e93<br \/>\nGit\u4ee3\u7801\u5e93\u53ef\u4ee5\u8bf4\u662f\u4e00\u4e2a\u5b8c\u6574\u7684\u6570\u636e\u5e93\uff0c\u5305\u542b\u4e86\u7ef4\u62a4\u548c\u7ba1\u7406\u9879\u76ee\u4fee\u8ba2\u7248\u672c\u548c\u5386\u53f2\u8bb0\u5f55\u6240\u9700\u7684\u6240\u6709\u4fe1\u606f\u3002Git\u4ee3\u7801\u5e93\u5177\u6709\u4e24\u4e2a\u57fa\u672c\u7684\u6570\u636e\u7ed3\u6784\uff1a\u5bf9\u8c61\u5b58\u50a8\u533a\u548c\u7d22\u5f15\u3002\u8be5\u4ee3\u7801\u5e93\u4e2d\u7684\u6570\u636e\u5168\u90e8\u4fdd\u5b58\u5728\u5de5\u4f5c\u76ee\u5f55\u6700\u9876\u5c42\u7684.git\u6587\u4ef6\u5939\u4e2d\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f Git \u4e2d\u300c\u5bf9\u8c61\u300d\u7684\u56db\u79cd\u7c7b\u578b\uff1a<\/p>\n<p>1. \u63d0\u4ea4\u5bf9\u8c61\uff08commit object\uff09<br \/>\n2. \u6807\u7b7e\u5bf9\u8c61\uff08tag object\uff09<br \/>\n3. \u6811\u5bf9\u8c61\uff08tree object\uff09<br \/>\n4. \u5feb\u7167\u5bf9\u8c61\uff08blob object\uff09<\/p>\n<p>\u30d6\u30ed\u30d6(blob)\u3000\u5927\u304d\u306a\u30d0\u30a4\u30ca\u30ea\u30aa\u30d6\u30b8\u30a7\u30af\u30c8(binary large object)\u306e\u77ed\u7e2e\u8868\u73fe\u3002\u30d5\u30a1\u30a4\u30eb\u306e\u5404\u30d0\u30fc\u30b8\u30e7\u30f3\u306f\u30d6\u30ed\u30d6\u3067\u8868\u3055\u308c\u308b\u3002<\/p>\n<p>\u30c4\u30ea\u30fc(tree)\u30001\u968e\u5c64\u5206\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u60c5\u5831\u3092\u8868\u73fe\u3059\u308b\u3002\u518d\u5e30\u7684\u306b\u4ed6\u306e\u30c4\u30ea\u30fc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53c2\u7167\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u3001\u3053\u308c\u306b\u3088\u308a\u30d5\u30a1\u30a4\u30eb\u3068\u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304b\u3089\u306a\u308b\u5b8c\u5168\u306a\u968e\u5c64\u69cb\u9020\u3092\u69cb\u7bc9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n<p>\u30b3\u30df\u30c3\u30c8(commit)\u3000\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u52a0\u3048\u3089\u308c\u305f\u5404\u5909\u66f4\u306e\u30e1\u30bf\u30c7\u30fc\u30bf\u3092\u4fdd\u6301\u3059\u308b\u3002\u5404\u30b3\u30df\u30c3\u30c8\u306f\u3001\u3042\u308b\u30c4\u30ea\u30fc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u6307\u3057\u793a\u3057\u3001\u3053\u306e\u30c4\u30ea\u30fc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f\u5358\u4e00\u306e\u5b8c\u5168\u306a\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u3068\u3057\u3066\u3001\u30b3\u30df\u30c3\u30c8\u304c\u5b9f\u884c\u3055\u308c\u305f\u6642\u70b9\u306b\u304a\u3051\u308b\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u72b6\u614b\u3092\u8a18\u9332\u3057\u3066\u3044\u308b\u3002<\/p>\n<p>\u30bf\u30b0(tag)\u3000\u7279\u5b9a\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5bfe\u3057\u3066\u3001\u304a\u305d\u3089\u304f\u4eba\u304c\u8aad\u3081\u308b\u540d\u524d\u3092\u3064\u3051\u308b\u3002\u540d\u524d\u3092\u3064\u3051\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f\u901a\u5e38\u30b3\u30df\u30c3\u30c8\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u3001\u4f8b\u3048\u30709da581d9109c&#8230;\u3068\u304b\u3092Ver1.0-alpha\u3068\u304b\u306b\u3059\u308b\u3002<\/p>\n<p>\u30fb\u7d22\u5f15<br \/>\n\u7d22\u5f15\u662f\u63cf\u8ff0\u5b58\u50a8\u5e93\u6574\u4e2a\u76ee\u5f55\u7ed3\u6784\u7684\u4e34\u65f6\u4e14\u52a8\u6001\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u3002\u7d22\u5f15\u6355\u6349\u4e86\u9879\u76ee\u5728\u67d0\u4e00\u65f6\u523b\u7684\u6574\u4f53\u7ed3\u6784\u3002<br \/>\n\u5982\u4f55\u5b9e\u73b0\u9010\u6b65\u5f00\u53d1\u548c\u63d0\u4ea4\u7684\u5206\u79bb\u3002\u5f00\u53d1\u8005\u901a\u8fc7\u6267\u884cGit\u547d\u4ee4\u5c06\u66f4\u6539\u6682\u5b58\u5230\u7d22\u5f15\u4e2d\uff08\u5982git add\u7b49\uff09\u3002\u7d22\u5f15\u8bb0\u5f55\u5e76\u4fdd\u6301\u66f4\u6539\uff0c\u76f4\u5230\u8fbe\u5230\u53ef\u4ee5\u63d0\u4ea4\u7684\u9636\u6bb5\uff0c\u5c06\u5176\u4fdd\u6301\u5728\u5b89\u5168\u72b6\u6001\u3002\u4e5f\u53ef\u4ee5\u5220\u9664\u6216\u66ff\u6362\u7d22\u5f15\u4e2d\u7684\u66f4\u6539\u3002\u901a\u8fc7\u7d22\u5f15\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u9010\u6e10\u4ece\u4e00\u4e2a\u590d\u6742\u7684\u5b58\u50a8\u5e93\u72b6\u6001\u8fc7\u6e21\u5230\u53ef\u80fd\u66f4\u597d\u7684\u53e6\u4e00\u4e2a\u72b6\u6001\u3002\u7d22\u5f15\u5728\u5408\u5e76\u4e2d\u4e5f\u626e\u6f14\u91cd\u8981\u89d2\u8272\u3002<\/p>\n<p>\u30fb\u5185\u5bb9\u53c3\u7167\u53ef\u80fd\u7684\u540d\u7a31<br \/>\n\u6bcf\u500b\u5132\u5b58\u5340\u4e2d\u7684\u7269\u4ef6\u90fd\u6709\u4e00\u500b\u7368\u7279\u7684\u540d\u7a31\uff0c\u9019\u500b\u540d\u7a31\u662f\u7531\u5c0d\u65bc\u7269\u4ef6\u5167\u5bb9\u61c9\u7528SHA1\u6240\u751f\u6210\u7684SHA1\u96dc\u6e4a\u503c\u6240\u7522\u751f\u7684\u3002SHA1\u7684\u503c\u662f\u4e00\u500b\u8868\u793a\u70ba40\u4f4d16\u9032\u5236\u6578\u5b57\u7684160\u4f4d\u503c\u3002Git\u4f7f\u7528\u8005\u6709\u6642\u6703\u5c07SHA1\u548c\u96dc\u6e4a\u78bc\uff0c\u751a\u81f3\u7269\u4ef6ID\u8996\u70ba\u76f8\u540c\u7684\u610f\u601d\u3002\u5c0d\u65bc\u76f8\u540c\u7684\u5167\u5bb9\uff0c\u4e0d\u8ad6\u5728\u54ea\u500b\u4f4d\u7f6e\uff0c\u90fd\u6703\u8a08\u7b97\u51fa\u76f8\u540c\u7684ID\u3002<\/p>\n<p>\u30fbGit\u8ffd\u8e2a\u5185\u5bb9<br \/>\nGit\u4e0d\u4ec5\u4ec5\u662f\u4e00\u4e2a\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u66f4\u50cf\u662f\u4e00\u4e2a\u5185\u5bb9\u8ffd\u8e2a\u7cfb\u7edf\u3002\u8fd9\u662fGit\u8bbe\u8ba1\u7406\u5ff5\u7684\u57fa\u7840\u3002<br \/>\nGit\u7684\u5185\u5bb9\u8ffd\u8e2a\u901a\u8fc7\u4e24\u4e2a\u91cd\u8981\u7684\u65b9\u9488\u6765\u4f53\u73b0\u3002<br \/>\n\u9996\u5148\uff0cGit\u7684\u5bf9\u8c61\u5b58\u50a8\u533a\u57df\u662f\u57fa\u4e8e\u5bf9\u8c61\u5185\u5bb9\u7684\u54c8\u5e0c\u8ba1\u7b97\uff0c\u4e0e\u539f\u59cb\u7528\u6237\u6587\u4ef6\u7ed3\u6784\u4e2d\u7684\u6587\u4ef6\u540d\u6216\u76ee\u5f55\u540d\u65e0\u5173\u3002\u5982\u679c\u5b58\u5728\u4f4d\u4e8e\u4e24\u4e2a\u4e0d\u540c\u76ee\u5f55\u4e2d\u7684\u5b8c\u5168\u76f8\u540c\u5185\u5bb9\u7684\u6587\u4ef6\uff0c\u5219Git\u53ea\u4f1a\u5728\u5bf9\u8c61\u5b58\u50a8\u533a\u57df\u4e2d\u4fdd\u5b58\u4e00\u4efd\u8be5\u5185\u5bb9\u7684\u62f7\u8d1d\u3002<br \/>\n\u5176\u6b21\uff0cGit\u7684\u5185\u90e8\u6570\u636e\u5e93\u53ef\u4ee5\u9ad8\u6548\u5730\u5b58\u50a8\u6bcf\u4e2a\u6587\u4ef6\u7684\u6bcf\u4e2a\u7248\u672c\uff0c\u800c\u4e0d\u662f\u5b58\u50a8\u5b83\u4eec\u7684\u5dee\u5f02\u3002\u5728Git\u4e2d\uff0c\u5de5\u4f5c\u548c\u5bf9\u8c61\u5b58\u50a8\u533a\u57df\u7684\u6761\u76ee\u4e0d\u80fd\u4ec5\u4ec5\u57fa\u4e8e\u6587\u4ef6\u5185\u5bb9\u7684\u90e8\u5206\u6216\u6587\u4ef6\u4e24\u4e2a\u7248\u672c\u4e4b\u95f4\u7684\u5dee\u5f02\u3002<\/p>\n<h3>\u535a\u78f7\u548c\u6811<\/h3>\n<p>\u900f\u8fc7\u5b9e\u9645\u7684\u4f8b\u5b50\uff0c\u6765\u89c2\u5bdf\u548c\u4e86\u89e3Blob\u548cTree\u7b49\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nb\">mkdir <\/span>hello\r\n<span class=\"nb\">cd <\/span>hello\r\ngit init\r\n<span class=\"nb\">echo<\/span> <span class=\"s2\">\"hello world\"<\/span> <span class=\"o\">&gt;<\/span> hello.txt\r\ngit add hello.txt\r\n<\/code><\/pre>\n<p>\u5982\u679c\u8981\u751f\u6210hello.txt\u6587\u4ef6\u5bf9\u8c61\uff08\u4f7f\u7528git add\uff09\uff0cGit\u4e0d\u4f1a\u5173\u5fc3\u6587\u4ef6\u540d\u662f\u5426\u662f&#8217;hello.txt&#8217;\u3002Git\u53ea\u5173\u5fc3\u6587\u4ef6\u7684\u5185\u5bb9\u662f&#8217;hello world&#8217;\u548c\u6700\u540e\u7684\u6362\u884c\u7b26\u3002\u5b83\u8ba1\u7b97SHA1\u54c8\u5e0c\u503c\uff0c\u5e76\u5c06\u5176\u547d\u540d\u4e3a\u54c8\u5e0c\u7684\u5341\u516d\u8fdb\u5236\u8868\u793a\u5f62\u5f0f\u4f5c\u4e3a\u5bf9\u8c61\u5b58\u50a8\u533a\u7684\u6587\u4ef6\u540d\u5b58\u50a8\u3002\u901a\u8fc7\u67e5\u770b.git\/objects\/\u53ef\u4ee5\u77e5\u9053\uff0c\u5b83\u4f1a\u521b\u5efa\u4ee5\u54c8\u5e0c\u503c\u7684\u524d\u4e24\u4f4d\u4e3a\u540d\u79f0\u7684\u76ee\u5f55\u5e76\u5c06\u6587\u4ef6\u653e\u7f6e\u5176\u4e2d\u3002\u7531\u4e8e\u6587\u4ef6\u7cfb\u7edf\u4e2d\u5c06\u592a\u591a\u7684\u6587\u4ef6\u653e\u5728\u540c\u4e00\u76ee\u5f55\u4e0b\u4f1a\u5bfc\u81f4\u6027\u80fd\u53d8\u6162\uff0c\u6240\u4ee5Git\u521b\u5efa\u4e86\u4e00\u4e2a\u5177\u6709\u5747\u5300\u5206\u5e03\u7684\u5bf9\u8c61\u7684\u56fa\u5b9a256\u5206\u5272\u7684\u547d\u540d\u7a7a\u95f4\u3002\u4f5c\u4e3aGit\u6ca1\u6709\u5bf9\u6587\u4ef6\u7684\u5185\u5bb9\u505a\u592a\u591a\u5904\u7406\u7684\u8bc1\u636e\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u54c8\u5e0c\u503c\u968f\u65f6\u4ece\u5bf9\u8c61\u5b58\u50a8\u533a\u4e2d\u63d0\u53d6\u6587\u4ef6\u7684\u5185\u5bb9\u3002<br \/>\n\u901a\u8fc7\u8fd0\u884cgit cat-file -p 3b18e512dba79e4c8300dd08aeb37f8e728b8dad\uff0c\u53ef\u4ee5\u770b\u5230\u663e\u793a\u4e86&#8217;hello world&#8217;\u3002\u4f7f\u7528cat-file\u547d\u4ee4\uff0c\u53ef\u4ee5\u901a\u8fc7\u7ed9\u5b9a\u7684\u54c8\u5e0c\u503c\u67e5\u770b\u6240\u6709\u5bf9\u8c61\uff08blob\u3001tree\u3001commit\u3001tag\uff09\u7684\u5185\u5bb9\u3002<\/p>\n<p>Git\u4f7f\u7528\u201c\u6811\u201d\u4f5c\u4e3a\u53e6\u4e00\u4e2a\u5bf9\u8c61\u6765\u8ddf\u8e2a\u8def\u5f84\u540d\u3002\u4f7f\u7528git add\u65f6\uff0cGit\u4f1a\u4e3a\u6bcf\u4e2a\u6dfb\u52a0\u7684\u6587\u4ef6\u521b\u5efa\u4e00\u4e2a\u5bf9\u8c61\u3002\u7136\u800c\uff0c\u5bf9\u8c61\u4e0d\u4f1a\u7acb\u5373\u521b\u5efa\u3002\u76f8\u53cd\uff0cGit\u4f1a\u66f4\u65b0\u7d22\u5f15\u3002\u7d22\u5f15\u4f4d\u4e8e.git\/index\u4e2d\uff0c\u5b83\u6301\u7eed\u8ddf\u8e2a\u6587\u4ef6\u7684\u8def\u5f84\u540d\u548c\u5bf9\u5e94\u7684blob\u3002\u5f53\u6267\u884cgit add\u3001git rm\u3001git mv\u7b49\u547d\u4ee4\u65f6\uff0cGit\u4f1a\u4f7f\u7528\u65b0\u7684\u8def\u5f84\u540d\u548c\u5bf9\u5e94\u7684blob\u4fe1\u606f\u66f4\u65b0\u7d22\u5f15\u3002\u7136\u540e\uff0c\u5728\u4efb\u4f55\u65f6\u5019\uff0c\u90fd\u53ef\u4ee5\u4f7f\u7528\u5f53\u524d\u7d22\u5f15\u521b\u5efa\u4e00\u4e2a\u6811\u5bf9\u8c61\u3002\u8981\u521b\u5efa\u6811\u5bf9\u8c61\uff0c\u53ef\u4ee5\u4f7f\u7528\u4f4e\u7ea7\u547d\u4ee4git write-tree\uff0c\u5b83\u4f1a\u5bf9\u5f53\u524d\u7d22\u5f15\u4fe1\u606f\u8fdb\u884c\u5feb\u7167\u3002<\/p>\n<p>\u4f7f\u7528git ls-files -s\u547d\u4ee4\uff0c\u53ef\u4ee5\u67e5\u770b\u7d22\u5f15\u3002<\/p>\n<pre class=\"post-pre\"><code>100644 3b18e512dba79e4c8300dd08aeb37f8e728b8dad 0   hello.txt\r\n<\/code><\/pre>\n<p>\u663e\u793a\u4e3a\u3002<\/p>\n<p>\u53ea\u9700\u4e00\u79cd\u9009\u9879\u6765\u7528\u4e2d\u6587\u8868\u8fbe\uff1a<br \/>\n\u5f53\u6355\u6349\u7d22\u5f15\u72b6\u6001\uff0c\u5e76\u4fdd\u5b58\u5230\u6811\u5bf9\u8c61\u4e2d\u65f6\uff0c\u9700\u8981\u4f7f\u7528git write-tree\u547d\u4ee4\u3002<br \/>\n\u6b64\u65f6<\/p>\n<pre class=\"post-pre\"><code>68aba62e560c0ebc3396e8ae9335232cd93a3f60\r\n<\/code><\/pre>\n<p>\u88ab\u8868\u793a\u4e3a\u3002<\/p>\n<p>\u7531\u4e8e\u6811\u662f\u5bf9\u8c61\uff0c\u56e0\u6b64\u8981\u50cf\u5904\u7406 Blob \u4e00\u6837\u67e5\u770b\u5176\u5185\u5bb9\u9700\u8981\u4f7f\u7528\u4f4e\u7ea7\u547d\u4ee4\u3002<br \/>\ngit cat-file -p 68aba6<\/p>\n<pre class=\"post-pre\"><code>100644 blob 3b18e512dba79e4c8300dd08aeb37f8e728b8dad    hello.txt\r\n<\/code><\/pre>\n<p>\u6700\u521d\u7684100644\u6570\u5b57\u4ee3\u8868\u4e86\u6587\u4ef6\u5c5e\u6027\uff08\u4f8b\u5982\u6700\u540e3\u4f4d\u7684644\u8868\u793arw-r&#8211;r&#8211;\uff09\u30023b18e512&#8230;\u4ee3\u8868\u4e86\u4e00\u4e2a\u540d\u4e3ahello world\u7684blob\u5bf9\u8c61\uff0c\u800chello.txt\u662f\u4e0e\u8be5blob\u5173\u8054\u7684\u540d\u79f0\u3002<\/p>\n<p>\u7136\u540e\u521b\u5efa\u4e00\u4e2a\u540d\u4e3asubdir\u7684\u5b50\u76ee\u5f55\uff0c\u5e76\u67e5\u770b\u5176\u5185\u5bb9\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nb\">mkdir <\/span>subdir\r\n<span class=\"nb\">cp <\/span>hello.txt subdir\r\ngit add subdir\/hello.txt\r\n<\/code><\/pre>\n<p>\u5982\u679c\u5728\u8fd9\u91cc\u4f7f\u7528git write-tree\u7684\u8bdd<\/p>\n<pre class=\"post-pre\"><code>492413269336d21fac079d4a4672e55d5d2147ac\r\n<\/code><\/pre>\n<p>\u88ab\u663e\u793a\u51fa\u6765<\/p>\n<p>\u5982\u679c\u5c06git cat-file -p 4924132\u4f5c\u4e3a\u547d\u4ee4\u7684\u8bdd\u3002<\/p>\n<pre class=\"post-pre\"><code>100644 blob 3b18e512dba79e4c8300dd08aeb37f8e728b8dad    hello.txt\r\n040000 tree 68aba62e560c0ebc3396e8ae9335232cd93a3f60    subdir\r\n<\/code><\/pre>\n<p>\u7136\u800c\uff0c\u5b50\u76ee\u9304\u4e2d\u7684\u5c0d\u8c61\u540d\u7a31\u8207\u5148\u524d\u7684git write-tree\u6307\u4ee4\u6240\u770b\u5230\u7684\u503c\u76f8\u540c\u3002\u9019\u662f\u56e0\u70ba\u5b50\u76ee\u9304\u4e2d\u7684\u65b0\u6a39\u8207\u4e4b\u524d\u7684\u6700\u9802\u5c64\u6a39\u5b8c\u5168\u76f8\u540c\u3002<\/p>\n<h3>\u63d0\u4ea4\u5bf9\u8c61<\/h3>\n<p>echo -n &#8220;Commit a file that says hello\\n&#8221; | git commit-tree 492413<br \/>\n\u6267\u884c\u540e\u5c06\u521b\u5efa\u63d0\u4ea4\u5bf9\u8c61\u3002<br \/>\n\u4e0e\u4ee5\u524d\u4e00\u6837\uff0c\u53ef\u4ee5\u4f7f\u7528git cat-file -p\u547d\u4ee4\u67e5\u770b\u5176\u5185\u5bb9\u3002\u5982\u679c\u662f\u5b9e\u9645\u6267\u884c\u6b64\u793a\u4f8b\u7684\u4eba\uff0c\u4ed6\u4eec\u5e94\u8be5\u77e5\u9053\u751f\u6210\u7684\u63d0\u4ea4\u5305\u62ec\u4f5c\u8005\u7684\u59d3\u540d\u548c\u65f6\u95f4\uff0c\u56e0\u6b64\u54c8\u5e0c\u503c\u4e0d\u4f1a\u5b8c\u5168\u76f8\u540c\u3002\u4f46\u662f\uff0c\u8fd9\u4e9b\u63d0\u4ea4\u5177\u6709\u76f8\u540c\u7684\u6811\u5bf9\u8c61\u3002\u4e0d\u540c\u7684\u63d0\u4ea4\u53ef\u80fd\u6307\u5411\u76f8\u540c\u7684\u6811\u5bf9\u8c61\u3002<\/p>\n<p>\u5b9e\u9645\u4e0a\uff0c\u6ca1\u6709\u5fc5\u8981\u4e5f\u4e0d\u5e94\u8be5\u4f7f\u7528\u4f4e\u7ea7\u522b\u7684 git write-tree \u6216 git commit-tree \u3002\u8fd9\u4e9b\u53ea\u662f\u7528\u4e8e\u5b66\u4e60\u76ee\u7684\uff0c\u5b9e\u9645\u4e0a\u5e94\u8be5\u4f7f\u7528 git commit \u547d\u4ee4\u3002<\/p>\n<p>\u57fa\u672c\u7684Git\u63d0\u4ea4\u5bf9\u8c61\u76f8\u5f53\u7b80\u5355\u3002\u800c\u8be5\u63d0\u4ea4\u5bf9\u8c61\u662f\u5b9e\u9645\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u6240\u5fc5\u9700\u7684\u6700\u540e\u4e00\u4e2a\u8981\u7d20\u3002\u63d0\u4ea4\u5bf9\u8c61\u5305\u62ec\u4ee5\u4e0b\u5185\u5bb9\uff1a<br \/>\n&#8211; \u5b9e\u9645\u8868\u793a\u76f8\u5173\u6587\u4ef6\u7684\u6811\u5bf9\u8c61\u7684\u540d\u79f0<br \/>\n&#8211; \u521b\u5efa\u65b0\u7248\u672c\u7684\u4f5c\u8005\u59d3\u540d\u548c\u521b\u5efa\u65f6\u95f4<br \/>\n&#8211; \u5c06\u65b0\u7248\u672c\u653e\u5165\u4ed3\u5e93\u7684\u4eba\uff08\u5373\u63d0\u4ea4\u8005\uff09\u7684\u59d3\u540d\u548c\u63d0\u4ea4\u65f6\u95f4<br \/>\n&#8211; \u63cf\u8ff0\u521b\u5efa\u6b64\u7248\u672c\u7684\u539f\u56e0\u7684\u8bf4\u660e\uff08\u63d0\u4ea4\u4fe1\u606f\uff09<\/p>\n<p>\u5982\u679c\u4f7f\u7528git show &#8211;pretty=fuller\u547d\u4ee4\uff0c\u60a8\u53ef\u4ee5\u67e5\u770b\u4e0a\u8ff0\u4fe1\u606f\u3002<\/p>\n<p>\u6b64\u5916\uff0c\u63d0\u4ea4\u5bf9\u8c61\u4ee5\u56fe\u5f62\u7ed3\u6784\u8fdb\u884c\u4fdd\u5b58\u3002\u7136\u800c\uff0c\u5b83\u4e0e\u6811\u5bf9\u8c61\u4f7f\u7528\u7684\u7ed3\u6784\u6709\u6839\u672c\u4e0a\u7684\u4e0d\u540c\u3002\u5728\u521b\u5efa\u65b0\u63d0\u4ea4\u65f6\uff0c\u53ef\u4ee5\u6307\u5b9a\u4e00\u4e2a\u6216\u591a\u4e2a\u7236\u63d0\u4ea4\u3002\u901a\u8fc7\u8ddf\u8e2a\u7236\u7ea7\u94fe\u6761\uff0c\u53ef\u4ee5\u67e5\u770b\u9879\u76ee\u7684\u5386\u53f2\u8bb0\u5f55\u3002<\/p>\n<h3>\u6807\u7b7e\u5bf9\u8c61<\/h3>\n<p>Git\u5904\u7406\u7684\u5bf9\u8c61\u7684\u7ed3\u5c3e\u662f\u6807\u7b7e\u3002Git\u4e2d\u53ea\u5b9e\u73b0\u4e86\u4e00\u79cd\u6807\u7b7e\u5bf9\u8c61\uff0c\u4f46\u6709\u4e24\u79cd\u57fa\u672c\u7c7b\u578b\u7684\u6807\u7b7e\uff1a\u8f7b\u91cf\u6807\u7b7e\u548c\u5e26\u6ce8\u91ca\u6807\u7b7e\u3002\u8fd9\u4e9b\u6807\u7b7e\u901a\u5e38\u88ab\u79f0\u4e3a\u8f7b\u91cf\u6807\u7b7e\u548c\u6ce8\u91ca\u6807\u7b7e\u3002<\/p>\n<p>\u8f7b\u91cf\u6807\u7b7e\u53ea\u662f\u7b80\u5355\u5730\u6307\u5411\u63d0\u4ea4\u5bf9\u8c61\uff0c\u901a\u5e38\u88ab\u8ba4\u4e3a\u662f\u5b58\u50a8\u5728\u4ed3\u5e93\u4e2d\u7684\u79c1\u6709\u5bf9\u8c61\u3002\u8fd9\u4e9b\u6807\u7b7e\u4e0d\u4f1a\u5728\u5bf9\u8c61\u5b58\u50a8\u533a\u521b\u5efa\u6c38\u4e45\u5bf9\u8c61\u3002<br \/>\n\u5e26\u6ce8\u91ca\u7684\u6807\u7b7e\u5219\u66f4\u6709\u5185\u5bb9\uff0c\u4f1a\u521b\u5efa\u5bf9\u8c61\u3002\u53ef\u4ee5\u5728\u5e26\u6ce8\u91ca\u7684\u6807\u7b7e\u4e2d\u5199\u5165\u6d88\u606f\u3002<\/p>\n<p>Git\u5728\u7ed9\u63d0\u4ea4\u6253\u4e0a\u6807\u7b7e\u7684\u76ee\u7684\u4e0a\uff0c\u8f7b\u91cf\u7ea7\u6807\u7b7e\u548c\u6ce8\u89e3\u6807\u7b7e\u662f\u4e00\u6837\u5bf9\u5f85\u7684\u3002\u7136\u800c\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5927\u591a\u6570Git\u547d\u4ee4\u53ea\u5bf9\u6ce8\u89e3\u6807\u7b7e\u8d77\u4f5c\u7528\u3002\u8fd9\u662f\u56e0\u4e3a\u6ce8\u89e3\u6807\u7b7e\u88ab\u89c6\u4e3a\u201c\u6c38\u4e45\u201d\u5bf9\u8c61\u3002<\/p>\n<p>\u8981\u4e3a\u63d0\u4ea4\u521b\u5efa\u5e26\u6709\u6ce8\u91ca\u548c\u6d88\u606f\u7684\u6807\u7b7e\uff0c\u53ef\u4ee5\u4f7f\u7528 git tag \u547d\u4ee4\u3002<\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u6807\u7b7e\u7248\u672c1.0\uff0c\u5e76\u9644\u5e26\u6d88\u606f&#8221;Tag version 1.0&#8243;\uff0c\u5c06\u5176\u4e0e\u6807\u8bc6\u7b26b59df5f\u5173\u8054\u8d77\u6765\u3002<\/p>\n<p>\u53ef\u4ee5\u50cf\u4e4b\u524d\u4e00\u6837\u4f7f\u7528git cat-file -p\u547d\u4ee4\u6765\u67e5\u770b\u6807\u7b7e\u5bf9\u8c61\u3002\u53ef\u4ee5\u4f7f\u7528git rev-parse\u547d\u4ee4\u67e5\u770b\u6807\u7b7e\u5bf9\u8c61\u7684SHA1\u503c\u3002<\/p>\n<p>\u53ea\u8981\u8f93\u5165git rev-parse V1.0<\/p>\n<pre class=\"post-pre\"><code>e4011b454a0442ffce1ed18b5a233c3c4122474c\r\n<\/code><\/pre>\n<p>\u56de\u5230\u6765\u3002<\/p>\n<p>\u5982\u679c\u4f7f\u7528 git cat-file -p e4011b<\/p>\n<pre class=\"post-pre\"><code>object b59df5f79d3cebc7896c104f3e189338fe6f9e74\r\ntype commit\r\ntag V1.0\r\ntagger git taro &lt;hello@example.com&gt; 1573473785 +0900\r\n\r\nTag version 1.0\r\n<\/code><\/pre>\n<p>\u6267\u884c\u5b8c\u547d\u4ee4\u540e\uff0c\u5c06\u8fd4\u56de\u4e00\u6761\u65e5\u5fd7\u6d88\u606f\uff0c\u5176\u4e2d\u5305\u62ec\u6700\u540e\u4e00\u6761\u65e5\u5fd7\u4fe1\u606f\u3001\u4f5c\u8005\u4fe1\u606f\uff0c\u4ee5\u53ca\u6307\u5411\u6807\u7b7e\u4e3ab59df5f\u7684\u63d0\u4ea4\u5bf9\u8c61\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cgit rev-parse\u547d\u4ee4\u53ef\u4ee5\u5c06\u4efb\u4f55\u5f62\u5f0f\u7684\u63d0\u4ea4\u540d\u79f0\uff08\u4f8b\u5982\u6807\u7b7e\u3001\u76f8\u5bf9\u540d\u79f0\u3001\u7b80\u5199\u7b49\uff09\u51c6\u786e\u5730\u8f6c\u6362\u4e3a\u54c8\u5e0c\u503c\u3002<\/p>\n<h2>\u5bf9\u4e8egit config\u76f8\u5173\u5185\u5bb9<\/h2>\n<p>\u6bcf\u6b21\u63d0\u4ea4\u65f6\uff0c\u53ef\u4ee5\u50cf\u8fd9\u6837\u4f7f\u7528`git commit -m &#8216;message&#8217; &#8211;author=&#8221;taro &lt;abc@example.com&gt;&#8221;`\u6765\u786e\u5b9a\u4f5c\u8005\u548c\u90ae\u7bb1\uff0c\u4f46\u66f4\u597d\u7684\u65b9\u6cd5\u662f\u5728config\u6587\u4ef6\u4e2d\u5199\u5165`git config user.name &#8216;taro&#8217;`\u548c`git config user.email &#8220;aa@example.com&#8221;`\u3002&#8211;author\u5fc5\u987b\u586b\u5199\u90ae\u7bb1\u3002<br \/>\n\u9664\u4e86\u4f7f\u7528git config\u547d\u4ee4\uff0c\u8fd8\u53ef\u4ee5\u901a\u8fc7\u73af\u5883\u53d8\u91cfGIT_AUTHOR_NAME\u6216GIT_AUTHOR_EMAIL\u6765\u8fdb\u884c\u914d\u7f6e\u3002<\/p>\n<p>\u30fbGit\u7684\u914d\u7f6e\u6587\u4ef6\u90fd\u662f\u4ee5.ini\u683c\u5f0f\u7684\u7b80\u5355\u6587\u672c\u6587\u4ef6\u3002\u4ee5\u4e0b\u6309\u4f18\u5148\u7ea7\u9ad8\u4f4e\u6392\u5217\uff1a<br \/>\n&#8211; .git\/config \u662f\u9488\u5bf9\u6bcf\u4e2a\u4ed3\u5e93\u7684\u914d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528&#8211;file\u9009\u9879\u8fdb\u884c\u64cd\u4f5c\u3002<br \/>\n&#8211; ~\/.gitconfig \u662f\u9488\u5bf9\u6bcf\u4e2a\u7528\u6237\u7684\u914d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528&#8211;global\u9009\u9879\u8fdb\u884c\u64cd\u4f5c\u3002<br \/>\n&#8211; \/etc\/gitconfig \u662f\u9488\u5bf9\u6574\u4e2a\u7cfb\u7edf\u7684\u914d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528&#8211;system\u9009\u9879\u8fdb\u884c\u64cd\u4f5c\u3002\u53ef\u80fd\u8fd8\u6709\u5176\u4ed6\u5730\u65b9\uff0c\u4f8b\u5982\/usr\/local\/etc\/gitconfig\u3002\u4e5f\u6709\u53ef\u80fd\u6839\u672c\u4e0d\u5b58\u5728\u8be5\u6587\u4ef6\u3002<\/p>\n<p>\u4f7f\u7528`gitconfig -global user.name &#8220;taro&#8221;`\u8fd9\u6837\u7684\u683c\u5f0f\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528 &#8220;git config -l&#8221; \u547d\u4ee4\u6765\u67e5\u770b\u53cd\u6620\u4e86\u6240\u6709\u914d\u7f6e\u6587\u4ef6\u503c\u7684\u8bbe\u7f6e\u503c\u5217\u8868\u3002<\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528&#8211;unset\u9009\u9879\u6765\u5220\u9664\u914d\u7f6e\u3002<br \/>\ngit config &#8211;global &#8211;unset user.email\u7b49\u7b49<\/p>\n<p>\u30fb\u9009\u62e9\u7f16\u8f91\u5668\u7684\u987a\u5e8f<br \/>\n1. GIT_EDITOR\u73af\u5883\u53d8\u91cf\uff08\u4f8b\u5982\uff0c\u5728bash\u4e2d\u4f7f\u7528export GIT_EDITOR=emacs\uff09<br \/>\n2. core.editor\u7684\u914d\u7f6e\u503c\uff08\u4f8b\u5982\uff0c\u4f7f\u7528git config &#8211;global core.editor emacs\uff09<br \/>\n3. VISUAL\u73af\u5883\u53d8\u91cf<br \/>\n4. EDITOR\u73af\u5883\u53d8\u91cf<br \/>\n5. vi\u547d\u4ee4<\/p>\n<p>\u30fb\u8bbe\u7f6e\u522b\u540d\u7684\u65b9\u6cd5<br \/>\ngit config &#8211;global alias.show-graph &#8216;log &#8211;graph &#8211;abbrev-commit &#8211;pretty=oneline&#8217;<br \/>\n\u901a\u8fc7\u8fd9\u4e2a\u65b9\u6cd5\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3ashow-graph\u7684\u522b\u540d\uff0c\u5b83\u6267\u884c\u4e86\u5728git log\u547d\u4ee4\u540e\u9762\u6dfb\u52a0\u4e86\u8bb8\u591a\u9009\u9879\u7684\u7ed3\u679c\uff08abbrev-commit\u662f\u5c06\u54c8\u5e0c\u503c\u7f29\u77ed\u663e\u793a\u7684\u9009\u9879\uff0cpretty=oneline\u662f\u5c06log\u4ee5\u7b80\u6d01\u7684\u4e00\u884c\u5f62\u5f0f\u663e\u793a\u7684\u9009\u9879\uff09\u3002<\/p>\n<h2>\u6587\u4ef6\u7ba1\u7406\u548c\u7d22\u5f15<\/h2>\n<p>\u5728Git\u7684\u90ae\u4ef6\u5217\u8868\u4e2d\uff0cLinus Torvalds\u4e3b\u5f20\u82e5\u4e0d\u5148\u7406\u89e3\u7d22\u5f15\u7684\u76ee\u7684\uff0c\u5219\u65e0\u6cd5\u771f\u6b63\u7406\u89e3\u548c\u8bc4\u4f30Git\u7684\u80fd\u529b\u3002git diff\u7528\u4e8e\u663e\u793a\u5de5\u4f5c\u76ee\u5f55\u4e2d\u672a\u6682\u5b58\u7684\u66f4\u6539\uff0c\u800cgit diff &#8211;cached\u7528\u4e8e\u663e\u793a\u5df2\u6682\u5b58\u4e14\u5c06\u5728\u4e0b\u6b21\u63d0\u4ea4\u4e2d\u4f7f\u7528\u7684\u66f4\u6539\u3002\u5728\u6682\u5b58\u66f4\u6539\u7684\u8fc7\u7a0b\u4e2d\uff0c\u8fd9\u4e24\u79cd\u7528\u6cd5\u90fd\u5bf9\u5de5\u4f5c\u975e\u5e38\u6709\u5e2e\u52a9\u3002\u6700\u521d\uff0cgit diff\u8868\u793a\u6240\u6709\u66f4\u6539\u90fd\u5305\u542b\u5728\u4e00\u4e2a\u5927\u96c6\u5408\u4e2d\uff0c\u800c&#8211;cached\u8868\u793a\u4e00\u4e2a\u7a7a\u72b6\u6001\u3002\u968f\u7740\u6682\u5b58\u7684\u8fdb\u884c\uff0c\u524d\u8005\u7684\u5927\u5c0f\u4f1a\u53d8\u5c0f\uff0c\u800c\u540e\u8005\u7684\u5927\u5c0f\u5219\u4f1a\u53d8\u5927\u3002<\/p>\n<p>\u5728Git\u4e2d\uff0c\u5c06\u6587\u4ef6\u5206\u4e3a\u4e09\u4e2a\u7ec4\u7684\u4e09\u79cd\u65b9\u6cd5\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u8ffd\u8de1(tracked) \u8ffd\u8de1\u30d5\u30a1\u30a4\u30eb\u3068\u306f\u3001\u3059\u3067\u306b\u30ec\u30dd\u30b8\u30c8\u30ea\u306b\u5165\u3063\u3066\u3044\u308b\u304b\u3001\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u767b\u9332\u3055\u308c\u3066\u3044\u308b\u30d5\u30a1\u30a4\u30eb\u3002\u65b0\u3057\u3044\u30d5\u30a1\u30a4\u30eb\u3092\u3053\u306e\u30b0\u30eb\u30fc\u30d7\u306b\u5165\u308c\u308b\u306b\u306fgit add\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u3046\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u7121\u8996(ignored) \u7121\u8996\u30d5\u30a1\u30a4\u30eb\u306f\u3001\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u304a\u3044\u3066\u660e\u793a\u7684\u306b\u300c\u898b\u3048\u306a\u3044\u300d\u300c\u7121\u8996\u3055\u308c\u3066\u3044\u308b\u300d\u3068\u5ba3\u8a00\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308b\u3002\u5ba3\u8a00\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u306f\u4f5c\u696d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u5b58\u5728\u3057\u3066\u3044\u3066\u3082\u3001\u7121\u8996\u3055\u308c\u308b\u3002Git\u306b\u30d5\u30a1\u30a4\u30eb\u3092\u7121\u8996\u3055\u305b\u308b\u306b\u306f\u3001.gitignore\u3068\u3044\u3046\u540d\u524d\u306e\u7279\u5225\u306a\u30d5\u30a1\u30a4\u30eb\u306b\u7121\u8996\u3055\u305b\u305f\u3044\u30d5\u30a1\u30a4\u30eb\u306e\u540d\u524d\u3092\u52a0\u3048\u308b\u3002\u4f8b\u3048\u3070echo main.o &gt; .gitignore\u3068\u304b\u3002\u521d\u3081\u3066.gitignore\u3092\u4f5c\u308b\u969b\u306f\u3001.gitignore\u81ea\u8eab\u306f\u672a\u8ffd\u8de1\u30d5\u30a1\u30a4\u30eb\u306b\u306a\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u672a\u8ffd\u8de1(untracked) \u672a\u8ffd\u8de1\u30d5\u30a1\u30a4\u30eb\u306f\u3001\u4e0a\u306e\u4e8c\u3064\u306e\u30b0\u30eb\u30fc\u30d7\u306e\u3069\u3061\u3089\u306b\u3082\u5c5e\u3055\u306a\u3044\u30d5\u30a1\u30a4\u30eb\u3002<\/ul>\n<p>\u521b\u5efa\u4e00\u4e2a.gitignore\u6587\u4ef6\u5e76\u8bd5\u9a8c\u4f7f\u7528\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nb\">mkdir <\/span>my_stuff\r\n<span class=\"nb\">cd <\/span>my_stuff\r\n<span class=\"nb\">echo<\/span> <span class=\"s2\">\"New data\"<\/span> <span class=\"o\">&gt;<\/span> data\r\ngit status\r\n<span class=\"nb\">touch <\/span>main.o\r\n<span class=\"nb\">echo <\/span>main.o <span class=\"o\">&gt;<\/span> .gitignore\r\ngit add data .gitignore\r\n<\/code><\/pre>\n<p>\u5728\u8fd9\u79cd\u72b6\u6001\u4e0b\uff0c\u4ece\u5bf9\u8c61\u6a21\u578b\u7684\u89d2\u5ea6\u770b\uff0c\u6bcf\u4e2a\u6587\u4ef6\u5728\u4f7f\u7528git add\u7684\u77ac\u95f4\u90fd\u4f1a\u88ab\u590d\u5236\u5230\u5bf9\u8c61\u5b58\u50a8\u533a\uff0c\u5e76\u901a\u8fc7\u5b58\u50a8\u4ea7\u751f\u7684SHA1\u503c\u521b\u5efa\u7d22\u5f15\u3002\u56e0\u6b64\uff0c\u5c06\u6587\u4ef6\u653e\u5165\u6682\u5b58\u533a\u4e5f\u53ef\u4ee5\u79f0\u4e3a&#8221;\u7f13\u5b58\u6587\u4ef6&#8221;\u6216&#8221;\u5c06\u6587\u4ef6\u653e\u5165\u7d22\u5f15&#8221;\u3002<br \/>\n\u901a\u8fc7\u4f7f\u7528git ls-files\u547d\u4ee4\uff0c\u53ef\u4ee5\u67e5\u770b\u5bf9\u8c61\u6a21\u578b\u7684\u5185\u90e8\u3002\u4f60\u4e5f\u53ef\u4ee5\u67e5\u770b\u5df2\u7ecf\u6682\u5b58\u7684\u6587\u4ef6\u7684SHA1\u503c\u3002<\/p>\n<p>git ls-files &#8211;stage \u53ef\u4ee5\u7528\u4ee5\u4e0b\u65b9\u5f0f\u6765\u8868\u8fbe\uff1a git ls-files &#8211;stage<\/p>\n<pre class=\"post-pre\"><code>100644 0487f44090ad950f61955271cf0a2d6c6a83ad9a 0   .gitignore\r\n100644 534469f67ae5ce72a7a274faf30dee3c2ea1746d 0   data\r\n<\/code><\/pre>\n<p>\u5728\u8fd9\u91cc\u7f16\u8f91\u6570\u636e\u3002\u5f53\u8f93\u5165cat data\u65f6\uff0c<\/p>\n<pre class=\"post-pre\"><code>New data\r\nAnd some more data now\r\n<\/code><\/pre>\n<p>\u4f7f\u7528git hash-object\u547d\u4ee4\uff08\u901a\u5e38\u60c5\u51b5\u4e0b\u4e0d\u4f7f\u7528\uff09\u5bf9\u6587\u4ef6\u8fdb\u884c\u7f16\u8f91\uff0c\u4ece\u800c\u8ba1\u7b97\u65b0\u7248\u672c\u6587\u4ef6\u7684\u54c8\u5e0c\u503c\u3002<\/p>\n<p>git\u54c8\u5e0c\u5bf9\u8c61[\u6570\u636e]<\/p>\n<pre class=\"post-pre\"><code>e476983f39f6e4f453f0fe4a859410f63b58b500\r\n<\/code><\/pre>\n<p>\u7531\u65bc\u5c1a\u672a\u57f7\u884cgit add\uff0c\u539f\u59cb\u7248\u672c\u5b58\u5132\u5340\u548c\u7d22\u5f15\u4e2d\u7684\u7248\u672c\u5177\u6709\u54c8\u5e0c\u503c534469f\u3002\u800c\u7576\u57f7\u884cgit add\u6642\uff0c\u5c07\u6703\u8f49\u8b8a\u70ba\u6b64\u6578\u503c\u3002<\/p>\n<p>\u5c06\u6570\u636e\u6dfb\u52a0\u5230Git\u4e2d<br \/>\n\u663e\u793a\u6587\u4ef6\u7684\u8be6\u7ec6\u4fe1\u606f<\/p>\n<pre class=\"post-pre\"><code>100644 0487f44090ad950f61955271cf0a2d6c6a83ad9a 0   .gitignore\r\n100644 e476983f39f6e4f453f0fe4a859410f63b58b500 0   data\r\n<\/code><\/pre>\n<p>\u4ece\u8fd9\u91cc\u53ef\u89c1\uff0cgit add \u4e0d\u5e94\u88ab\u7406\u89e3\u4e3a\u201c\u6dfb\u52a0\u6307\u5b9a\u6587\u4ef6\u201d\uff0c\u800c\u5e94\u7406\u89e3\u4e3a\u201c\u6dfb\u52a0\u6307\u5b9a\u5185\u5bb9\u201d\u3002<\/p>\n<p>\u5982\u679c\u5728\u547d\u4ee4\u884c\u4e2d\u4e0d\u6307\u5b9a\u63d0\u4ea4\u65e5\u5fd7\u4fe1\u606f\uff0cGit\u4f1a\u542f\u52a8\u7f16\u8f91\u5668\u5e76\u63d0\u793a\u4f60\u7f16\u5199\u65e5\u5fd7\u4fe1\u606f\u3002\u5982\u679c\u5728\u7f16\u5199\u63d0\u4ea4\u65e5\u5fd7\u4fe1\u606f\u65f6\u56e0\u67d0\u79cd\u539f\u56e0\u51b3\u5b9a\u4e0d\u63d0\u4ea4\uff0c\u53ea\u9700\u5728\u4e0d\u4fdd\u5b58\u7684\u60c5\u51b5\u4e0b\u9000\u51fa\u7f16\u8f91\u5668\u5373\u53ef\u3002\u5982\u679c\u5df2\u7ecf\u4fdd\u5b58\u4e86\u63d0\u4ea4\u65e5\u5fd7\u4fe1\u606f\uff0c\u53ea\u9700\u5220\u9664\u6574\u4e2a\u65e5\u5fd7\u4fe1\u606f\u5e76\u91cd\u65b0\u4fdd\u5b58\u5373\u53ef\u3002<\/p>\n<p>\u4f7f\u7528git rm\u547d\u4ee4<\/p>\n<p>\u4e3a\u4e86\u5c06\u6587\u4ef6\u4ece\u6682\u5b58\u72b6\u6001\u53d8\u4e3a\u672a\u6682\u5b58\u72b6\u6001\uff0c\u53ef\u4ee5\u4f7f\u7528git rm &#8211;cached\u547d\u4ee4\u3002\u8be5\u547d\u4ee4\u4f1a\u4ece\u7d22\u5f15\u4e2d\u79fb\u9664\u6587\u4ef6\uff0c\u4f46\u4ecd\u4fdd\u7559\u5728\u5de5\u4f5c\u76ee\u5f55\u4e2d\u3002\u5c06\u6587\u4ef6\u4fdd\u7559\u5728\u5de5\u4f5c\u76ee\u5f55\u4e2d\u4e14\u53d8\u4e3a\u672a\u8ddf\u8e2a\u72b6\u6001\u662f\u5371\u9669\u7684\uff0c\u56e0\u4e3a\u53ef\u80fd\u4f1a\u5fd8\u8bb0\u8be5\u6587\u4ef6\u4e0d\u518d\u88ab\u8ffd\u8e2a\u3002<\/p>\n<p>Git\u5728\u5220\u9664\u6587\u4ef6\u4e4b\u524d\uff0c\u4f1a\u68c0\u67e5\u5de5\u4f5c\u76ee\u5f55\u4e2d\u6587\u4ef6\u7684\u7248\u672c\u662f\u5426\u4e3a\u5f53\u524d\u5206\u652f\u7684\u6700\u65b0\u7248\u672c\uff08Git\u547d\u4ee4\u79f0\u4e3aHEAD\u7248\u672c\uff09\u3002\u8fd9\u4e2a\u68c0\u67e5\u53ef\u4ee5\u9632\u6b62\u5bf9\u6587\u4ef6\u7684\u66f4\u6539\u610f\u5916\u4e22\u5931\u3002\u8981\u4f7fgit rm\u5de5\u4f5c\uff0c\u5de5\u4f5c\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\u5fc5\u987b\u4e0eHEAD\u6216\u7d22\u5f15\u7684\u5185\u5bb9\u76f8\u5339\u914d\u3002<\/p>\n<p>\u30fb\u4f7f\u7528 git mv<\/p>\n<pre class=\"post-pre\"><code>mv stuff newstuff\r\ngit rm stuff\r\ngit add newstuff\r\n<\/code><\/pre>\n<p>\u8fd9\u4e09\u4e2a\u547d\u4ee4(mv, git rm, git add)\u4ee5\u53ca\u4e0b\u4e00\u4e2a\u547d\u4ee4(git mv)\u662f\u7b49\u4ef7\u7684\u3002<\/p>\n<pre class=\"post-pre\"><code>git mv stuff newstuff\r\n<\/code><\/pre>\n<p>\u5c06\u5df2\u7ecfgit mv\u7684\u6587\u4ef6\u8fdb\u884c\u65b0\u7684\u63d0\u4ea4\u3002<\/p>\n<pre class=\"post-pre\"><code>git <span class=\"nb\">mv <\/span>data mydata\r\ngit commit <span class=\"nt\">-m<\/span> <span class=\"s2\">\"moved data to mydata\"<\/span>\r\ngit log mydata\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>commit 916336aec421a6923e4ff1d53afab343afcb1f96 (HEAD -&gt; master)\r\nAuthor: git taro &lt;hello@example.com&gt;\r\nDate:   Tue Nov 12 01:10:14 2019 +0900\r\n\r\n    moved data to mydata\r\n<\/code><\/pre>\n<p>\u5f53\u67e5\u770bmydata\u7684\u5386\u53f2\u8bb0\u5f55\u65f6\uff0c\u770b\u8d77\u6765\u4f3c\u4e4e\u4e22\u5931\u4e86data\u65f6\u671f\u7684\u5386\u53f2\u8bb0\u5f55\uff0c\u4f46\u5b9e\u9645\u4e0a\u5e76\u6ca1\u6709\u4e22\u5931\u3002\u8981\u67e5\u770bdata\u65f6\u671f\u7684\u5386\u53f2\u8bb0\u5f55\uff0c\u53ea\u9700\u4f7f\u7528&#8211;follow\u547d\u4ee4\u5373\u53ef\u3002<\/p>\n<p>\u67e5\u770b\u6211\u7684\u6570\u636e\u7684 git \u65e5\u5fd7 &#8211;follow<\/p>\n<pre class=\"post-pre\"><code>commit 916336aec421a6923e4ff1d53afab343afcb1f96 (HEAD -&gt; master)\r\nAuthor: git taro &lt;hello@example.com&gt;\r\nDate:   Tue Nov 12 01:10:14 2019 +0900\r\n\r\n    moved data to mydata\r\n\r\ncommit d98e81e11877e16d2bdd6e42853a6344b8ba299c\r\nAuthor: git taro &lt;hello@example.com&gt;\r\nDate:   Tue Nov 12 00:44:20 2019 +0900\r\n\r\n    hello\r\n<\/code><\/pre>\n<p>\u6b63\u786e\u663e\u793a\u4e86\u4e4b\u524d\u7684\u63d0\u4ea4\u3002<\/p>\n<p>\u30fb.gitignore\u6587\u4ef6<\/p>\n<p>.gitignore\u6587\u4ef6\u4e0d\u4ec5\u53ef\u4ee5\u653e\u5728\u5b58\u50a8\u5e93\u7684\u6700\u9ad8\u7ea7\u76ee\u5f55\u4e0b\uff0c\u8fd8\u53ef\u4ee5\u653e\u5728\u5176\u5b50\u76ee\u5f55\u4e0b\u3002\u5c06\u5176\u653e\u7f6e\u5728\u6700\u9ad8\u7ea7\u76ee\u5f55\u4e0b\u53ef\u4ee5\u4f7f\u5b58\u50a8\u5e93\u4e2d\u7684\u6240\u6709\u5730\u65b9\u90fd\u80fd\u5ffd\u7565\u8be5\u6587\u4ef6\u3002<\/p>\n<p>.gitignore\u6587\u4ef6\u7684\u683c\u5f0f\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u7a7a\u884c\u306f\u7121\u8996\u3001#\u3067\u59cb\u307e\u308b\u884c\u306f\u30b3\u30e1\u30f3\u30c8\u306b\u306a\u308b\u3002\u884c\u306e\u9014\u4e2d\u304b\u3089#\u3092\u4f7f\u3063\u3066\u3082\u30b3\u30e1\u30f3\u30c8\u306b\u306f\u306a\u3089\u306a\u3044\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u540d\u306f\u3001\u672b\u5c3e\u306e\/\u306b\u3088\u3063\u3066\u8868\u3055\u308c\u308b\u3002\u3053\u308c\u306f\u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u3082\u30de\u30c3\u30c1\u3059\u308b\u3002\u305f\u3060\u3057\u30d5\u30a1\u30a4\u30eb\u3084\u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\u306b\u306f\u30de\u30c3\u30c1\u3057\u306a\u3044\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">*\u306e\u3088\u3046\u306a\u30b7\u30a7\u30eb\u306e\u30b0\u30ed\u30d6\u6587\u5b57\u3092\u542b\u3080\u5834\u5408\u306f\u3001\u30b7\u30a7\u30eb\u306e\u30b0\u30ed\u30d6\u30d1\u30bf\u30fc\u30f3\u3068\u3057\u3066\u5c55\u958b\u3055\u308c\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u884c\u982d\u306e\u611f\u5606\u7b26\u306f\u3001\u884c\u306e\u6b8b\u308a\u306e\u90e8\u5206\u306e\u30d1\u30bf\u30fc\u30f3\u306e\u610f\u5473\u3092\u53cd\u8ee2\u3055\u305b\u308b\u3002\u52a0\u3048\u3066\u3001\u3053\u308c\u3088\u308a\u524d\u306e\u30d1\u30bf\u30fc\u30f3\u3067\u9664\u5916\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u306e\u3046\u3061\u3001\u53cd\u8ee2\u3057\u305f\u30eb\u30fc\u30eb\u306b\u30de\u30c3\u30c1\u3059\u308b\u8005\u306f\u518d\u3073\u542b\u3081\u308b\u3002<\/ul>\n<p>\u5982\u679c\u9664\u5916\u6a21\u5f0f\u4ee5\u67d0\u79cd\u65b9\u5f0f\u4e13\u95e8\u9488\u5bf9\u60a8\u7684\u5b58\u50a8\u5e93\uff0c\u5e76\u4e14\u4e0d\u5e94\u5e94\u7528\u4e8e\u5176\u4ed6\u7528\u6237\u7684\u5b58\u50a8\u5e93\u514b\u9686\uff0c\u5219\u5e94\u5c06\u8be5\u6a21\u5f0f\u653e\u5165.git\/info\/exclude\u6587\u4ef6\u4e2d\u3002\u8fd9\u6837\u4e00\u6765\uff0c\u5b83\u5c06\u4e0d\u4f1a\u901a\u8fc7\u514b\u9686\u64cd\u4f5c\uff08git clone\uff09\u8fdb\u884c\u4f20\u64ad\u3002<\/p>\n<h2>\u63d0\u4ea4<\/h2>\n<p>\u30fb\u63d0\u4ea4\u7684\u7edd\u5bf9\u540d\u79f0<br \/>\n\u63d0\u4ea4\u7684\u54c8\u5e0cID\u4f5c\u4e3a\u63d0\u4ea4\u7684\u540d\u79f0\u662f\u6700\u4e25\u683c\u7684\u3002\u4f8b\u5982\uff0c\u5f53\u67d0\u4e2a\u5f00\u53d1\u8005\u901a\u8fc7\u8054\u7cfb\u65b9\u5f0f\u5f15\u7528\u81ea\u5df1\u5b58\u50a8\u5e93\u4e2d\u7684\u67d0\u4e2a\u63d0\u4ea4ID\u65f6\uff0c\u5982\u679c\u5728\u60a8\u7684\u5b58\u50a8\u5e93\u4e2d\u5b58\u5728\u8be5\u63d0\u4ea4\uff0c\u90a3\u4e48\u53ef\u4ee5\u8bf4\u4e24\u4eba\u770b\u5230\u7684\u63d0\u4ea4\u5b8c\u5168\u76f8\u540c\u3002\u7528\u4e8e\u8ba1\u7b97\u63d0\u4ea4ID\u7684\u6570\u636e\u5305\u62ec\u6574\u4e2a\u5b58\u50a8\u5e93\u6811\u4ee5\u53ca\u5148\u524d\u63d0\u4ea4\u7684\u72b6\u6001\uff0c\u56e0\u6b64\u4ece\u5f52\u7eb3\u4e0a\u6765\u770b\uff0c\u60a8\u548c\u8be5\u5f00\u53d1\u8005\u5b8c\u5168\u770b\u5230\u4e86\u5305\u62ec\u5f00\u53d1\u7ebf\u5728\u5185\u7684\u5bfc\u81f4\u8be5\u63d0\u4ea4\u7684\u5185\u5bb9\u5b8c\u5168\u76f8\u540c\u3002<\/p>\n<p>\u30fb\u53c2\u8003\u548c\u7b26\u53f7\u5f15\u7528<br \/>\n\u53c2\u8003\u662fGit\u5bf9\u8c61\u5b58\u50a8\u533a\u57df\u5185\u7684\u5bf9\u8c61\u7684SHA1\u54c8\u5e0cID\u7684\u5f15\u7528\u3002\u7b26\u53f7\u5f15\u7528\u662f\u95f4\u63a5\u6307\u5411Git\u5bf9\u8c61\u7684\u540d\u79f0\u3002\u4f8b\u5982\uff0c\u672c\u5730\u7684\u4e3b\u9898\u5206\u652f\uff0c\u8fdc\u7a0b\u8ddf\u8e2a\u5206\u652f\u548c\u6807\u7b7e\u7684\u540d\u79f0\u90fd\u662f\u5f15\u7528\u3002<br \/>\n\u7b26\u53f7\u5f15\u7528\u90fd\u5177\u6709\u4ee5refs\/\u5f00\u5934\u7684\u660e\u786e\u7684\u7edd\u5bf9\u540d\u79f0\uff0c\u5e76\u4e14\u4ee5\u5206\u5c42\u65b9\u5f0f\u653e\u7f6e\u5728\u5b58\u50a8\u5e93\u7684.git\/refs\/\u76ee\u5f55\u4e2d\u3002\u5728refs\/\u4e0b\u901a\u5e38\u6709\u4e09\u4e2a\u4e0d\u540c\u7684\u547d\u540d\u7a7a\u95f4\u3002\u5206\u522b\u7528\u4e8e\u672c\u5730\u5206\u652f\u7684refs\/heads\/ref\uff0c\u8fdc\u7a0b\u8ddf\u8e2a\u5206\u652f\u7684refs\/remotes\/ref\u548c\u6807\u7b7e\u7684refs\/tags\/ref\u3002\u4f8b\u5982\uff0c\u50cfv2.6.23\u8fd9\u6837\u7684\u6807\u7b7e\u662frefs\/tags\/v2.6.23\u7684\u7f29\u5199\u3002<\/p>\n<p>\u30fb\u76f8\u5bf9\u7684\u63d0\u4ea4\u540d\u79f0<br \/>\nmaster^ \u59cb\u7ec8\u6307\u7684\u662f master \u5206\u652f\u4e0a\u7684\u7b2c\u4e8c\u4e2a\u63d0\u4ea4\u3002\u4e5f\u53ef\u4ee5\u662f master^^\u3002\u9664\u4e86\u521d\u59cb\u63d0\u4ea4\u7684\u6839\u63d0\u4ea4\u5916\uff0c\u6bcf\u4e2a\u63d0\u4ea4\u90fd\u6709\u4e00\u4e2a\u6216\u591a\u4e2a\u7236\u63d0\u4ea4\u3002\u5408\u5e76\u64cd\u4f5c\u4f1a\u6709\u4e24\u4e2a\u4ee5\u4e0a\u7684\u7236\u63d0\u4ea4\u3002\u5728\u67d0\u4e00\u4ee3\u4e2d\uff0c\u4f7f\u7528 ^\uff08\u8131\u5b57\u7b26\uff09\u6765\u9009\u62e9\u4e0d\u540c\u7684\u7236\u63d0\u4ea4\u3002\u4f7f\u7528 ~\uff08\u6ce2\u6d6a\u53f7\uff09\u6765\u904d\u5386\u7956\u5148\u5e76\u9009\u62e9\u524d\u4e00\u4ee3\u7684\u63d0\u4ea4\u3002master^ \u548c master~ \u90fd\u662f\u7b80\u5199\u5f62\u5f0f\uff0cmaster^ \u8868\u793a master^1\uff0cmaster~ \u8868\u793a master~1 \u7684\u610f\u601d\u3002<\/p>\n<p>\u53ef\u4ee5\u5c06git rev-parse master~3^2^2^\u8fd9\u6837\u591a\u4e2a\u7ec4\u5408\u5728\u4e00\u8d77\u3002<\/p>\n<p>Git\u547d\u4ee4rev-parse\u7684\u4e3b\u8981\u529f\u80fd\u662f\u5c06\u5404\u79cd\u683c\u5f0f\u7684\u63d0\u4ea4\u540d\u79f0\uff08\u5982\u6807\u7b7e\u3001\u76f8\u5bf9\u540d\u79f0\u3001\u7701\u7565\u5f62\u5f0f\u7b49\uff09\u8f6c\u6362\u4e3a\u5b9e\u9645\u5b58\u50a8\u5728\u5bf9\u8c61\u6570\u636e\u5e93\u4e2d\u7684\u63d0\u4ea4\u54c8\u5e0cID\u3002<\/p>\n<p>\u5173\u4e8egit log\u7684\u5185\u5bb9<br \/>\n\u8981\u67e5\u770b\u63d0\u4ea4\u8bb0\u5f55\uff0c\u53ef\u4ee5\u4f7f\u7528git log\u547d\u4ee4\u3002\u5982\u679c\u4e0d\u6307\u5b9a\u53c2\u6570\uff0c\u5219\u7c7b\u4f3c\u4e8egit log HEAD\u7684\u884c\u4e3a\u3002\u5f53\u6307\u5b9a\u67d0\u4e2a\u63d0\u4ea4\u65f6\uff0c\u4f1a\u4ece\u6307\u5b9a\u7684\u63d0\u4ea4\u5411\u540e\u663e\u793a\u3002\u4f8b\u5982\uff0cgit log master\u4e4b\u7c7b\u7684\u3002<\/p>\n<p>\u7528\u6237\u53ef\u4ee5\u4f7f\u7528&#8221;since..until&#8221;\u7684\u683c\u5f0f\u6765\u6307\u5b9a\u63d0\u4ea4\u7684\u8303\u56f4\u3002<\/p>\n<p>git log &#8211;pretty=short &#8211;abbrev-commit master\u7684\u524d12\u4e2a\u7248\u672c\u5230master\u7684\u524d10\u4e2a\u7248\u672c<\/p>\n<p>\u5728\u4e2d\u6587\u4e2d\u7528\u4e00\u79cd\u65b9\u5f0f\u6765\u6539\u8ff0\uff1a<br \/>\n&#8211;pretty \u9009\u9879\u53ef\u4ee5\u9009\u62e9 oneline\u3001short\u3001full\uff0c\u4ee5\u8c03\u6574\u63d0\u4ea4\u7684\u663e\u793a\u6570\u91cf\u3002&#8211;abbrev \u9009\u9879\u53ef\u4ee5\u7b80\u5316\u8868\u793a\u54c8\u5e0c ID\u3002<\/p>\n<p>\u4f7f\u7528-p\u9009\u9879\u53ef\u4ee5\u663e\u793a\u63d0\u4ea4\u6240\u5e26\u6765\u7684\u5dee\u5f02\u3002\u800c\u901a\u8fc7-n\u9009\u9879\uff0c\u4f60\u53ef\u4ee5\u5c06\u8f93\u51fa\u9650\u5236\u4e3a\u6700\u65b0\u7684n\u4e2a\u63d0\u4ea4\u3002<\/p>\n<p>\u5728\u5bf9\u8c61\u5b58\u50a8\u533a\u57df\u4e2d\u6709\u53e6\u4e00\u4e2a\u547d\u4ee4\u7528\u4e8e\u663e\u793a\u5bf9\u8c61\uff0c\u5b83\u79f0\u4e3agit show\u3002<\/p>\n<p>\u6bd4\u5982\u8bf4git show HEAD^2\u4e4b\u7c7b\u7684\u547d\u4ee4\u3002\u5373\u4fbf\u6307\u5b9a\u4e86\u6807\u7b7e\u7684\u54c8\u5e0cID\u6216\u6811\u7684\u54c8\u5e0cID\uff0c\u5b83\u4e5f\u80fd\u6b63\u786e\u5730\u5c55\u793a\u51fa\u6765\u3002<\/p>\n<p>\u8981\u67e5\u770b\u63d0\u4ea4\u56fe\u8868\uff0c\u53ef\u4ee5\u4f7f\u7528gitk\u547d\u4ee4\u3002\u7136\u800c\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\u6709\u65f6\u5019\u53ef\u80fd\u6ca1\u6709\u5b89\u88c5\u8fd9\u4e2a\u547d\u4ee4\u3002<\/p>\n<p>\u5f88\u591aGit\u547d\u4ee4\u53ef\u4ee5\u6307\u5b9a\u63d0\u4ea4\u8303\u56f4\u3002\u8303\u56f4\u53ef\u4ee5\u7528\u4e24\u4e2a\u53e5\u70b9\u8868\u793a\uff0c\u4f8b\u5982start..end\u3002\u524d\u9762\u7684\u4f8b\u5b50\u4e5f\u662f\u4e00\u6837\uff08master~12..master~10\u90e8\u5206\uff09\u3002\u5982\u679c\u4e0d\u6307\u5b9astart\u6216end\uff0c\u90a3\u4e48HEAD\u5c06\u88ab\u7528\u5728\u90a3\u4e2a\u4f4d\u7f6e\u3002<\/p>\n<p>\u5f53\u5728git log\u4e2d\u6307\u5b9a\u63d0\u4ea4Y\u65f6\uff0c\u5b9e\u9645\u4e0a\u53ef\u4ee5\u770b\u5230\u6240\u6709\u53ef\u5230\u8fbe\u7684\u63d0\u4ea4\u65e5\u5fd7\uff08\u53ef\u5230\u8fbe\u662f\u56fe\u8bba\u672f\u8bed\uff0c\u8868\u793a\u53ef\u4ee5\u901a\u8fc7\u904d\u5386\u56fe\u7684\u8fb9\u5230\u8fbe\uff09\u3002\u8868\u8fbe\u5f0f^X\u8868\u793a\u53ef\u4ee5\u6392\u9664\u63d0\u4ea4X\u548c\u53ef\u5230\u8fbeX\u7684\u6240\u6709\u63d0\u4ea4\u3002git log ^X Y\u548cgit log X..Y\u5177\u6709\u76f8\u540c\u7684\u542b\u4e49\u3002\u4ece\u53ef\u5230\u8fbe\u63d0\u4ea4Y\u5f00\u59cb\uff0c\u5305\u62ecX\u901a\u5411X\u7684\u63d0\u4ea4\u662f\u4e0d\u5fc5\u8981\u7684\uff0c\u6570\u5b66\u4e0a\u6765\u8bf4^X Y\u548cX..Y\u662f\u7b49\u4ef7\u7684\u3002\u4e5f\u53ef\u4ee5\u5c06\u5176\u89c6\u4e3a\u96c6\u5408\u7684\u5dee\u96c6\u8fd0\u7b97\u3002<\/p>\n<p>A&#8230;B\u8868\u793aA\u548cB\u4e4b\u95f4\u7684\u76f8\u5bf9\u5dee\u5f02\u3002\u8868\u793a\u53ef\u4ee5\u4eceA\u6216B\u4e2d\u7684\u4efb\u610f\u4e00\u4e2a\u5230\u8fbe\uff0c\u4f46\u4e0d\u80fd\u4ece\u4e24\u8005\u90fd\u5230\u8fbe\u7684\u63d0\u4ea4\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u6267\u884c\u66f4\u5f3a\u5927\u7684\u63d0\u4ea4\u96c6\u5408\u8fd0\u7b97\u3002\u53ef\u4ee5\u5728\u6307\u5b9a\u8303\u56f4\u7684\u547d\u4ee4\u4e2d\uff0c\u81ea\u7531\u5730\u6392\u5217\u5305\u542b\u6216\u4e0d\u5305\u542b\u7684\u63d0\u4ea4\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4git log ^dev ^topic ^bugfix master\u9009\u62e9\u5728master\u5206\u652f\u4e2d\u65e2\u4e0d\u5c5e\u4e8edev\u3001topic\uff0c\u4e5f\u4e0d\u5c5e\u4e8ebugfix\u7684\u63d0\u4ea4\u3002<\/p>\n<p>\u30fbGit\u5206\u652f<br \/>\nGit\u5206\u652f\u547d\u4ee4\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u53ef\u6839\u636e\u4efb\u610f\u7684\u641c\u7d22\u6761\u4ef6\uff0c\u5206\u79bb\u51fa\u5177\u6709\u7279\u5b9a\u7f3a\u9677\u7684\u63d0\u4ea4\u3002\u901a\u8fc7\u4f7f\u7528git bisect start\u5f00\u59cb\u641c\u7d22\uff0cgit bisect good\u6307\u5b9a\u597d\u7684\u63d0\u4ea4\u72b6\u6001\uff0cgit bisect bad\u6307\u5b9a\u574f\u7684\u63d0\u4ea4\u72b6\u6001\uff0c\u53cd\u590d\u8fdb\u884c\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u4ee5\u627e\u5230\u7279\u5b9a\u7684\u63d0\u4ea4\u3002\u5f53\u5b8c\u6210\u65f6\uff0c\u4f7f\u7528git bisect reset\u547d\u4ee4\u5c06HEAD\u6062\u590d\u5230\u521d\u59cb\u72b6\u6001\u3002<\/p>\n<p>\u4f7f\u7528git blame\u547d\u4ee4\u53ef\u4ee5\u627e\u5230\u7279\u5b9a\u7684\u63d0\u4ea4\u3002\u901a\u8fc7\u547d\u4ee4git blame\u6587\u4ef6\u540d\uff0c\u53ef\u4ee5\u663e\u793a\u6587\u4ef6\u7684\u6bcf\u4e00\u884c\u662f\u7531\u8c01\u5728\u6700\u540e\u7f16\u8f91\u7684\uff0c\u5e76\u5728\u54ea\u4e2a\u63d0\u4ea4\u4e2d\u53d1\u751f\u7684\u66f4\u6539\u3002\u5982\u679c\u52a0\u4e0a-L n\u9009\u9879\uff0c\u53ef\u4ee5\u4ece\u7b2cn\u884c\u5f00\u59cb\u663e\u793a\u3002<\/p>\n<p>\u4f7f\u7528git log\u7684-S\u9009\u9879\uff0c\u53ef\u4ee5\u56de\u6eaf\u6587\u4ef6\u5dee\u5f02\u7684\u5386\u53f2\u5e76\u641c\u7d22\u5b57\u7b26\u4e32\u3002\u7531\u4e8e\u5728\u4fee\u8ba2\u4e4b\u95f4\u8fdb\u884c\u641c\u7d22\u5b9e\u9645\u5dee\u5f02\uff0c\u56e0\u6b64\u53ef\u4ee5\u627e\u5230\u6dfb\u52a0\u548c\u5220\u9664\u7684\u4efb\u4f55\u66f4\u6539\u3002\u5bf9\u4e8egit log\u7684-S\u9009\u9879\uff0c\u88ab\u79f0\u4e3a\u201c\u9504\u5934\u201d\uff08pickaxe\uff09\uff0c\u53ef\u7528\u4e8e\u5f3a\u5236\u6316\u6398\u3002<\/p>\n<h2>\u5206\u652f<\/h2>\n<p>\u521b\u5efa\u5206\u652f\u7684\u539f\u56e0\u6709\u5f88\u591a\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u53ef\u4ee5\u8003\u8651\u4ee5\u4e0b\u51e0\u4e2a\u539f\u56e0\uff1a<br \/>\n&#8211; \u4ee3\u8868\u4e3a\u4e2a\u522b\u5ba2\u6237\u53d1\u5e03\u7684\u7248\u672c<br \/>\n&#8211; \u4ee3\u8868\u5f00\u53d1\u9636\u6bb5\uff0c\u5982\u539f\u578b\u53d1\u5e03\u3001Beta\u53d1\u5e03\u3001\u7a33\u5b9a\u53d1\u5e03\u3001\u5b9e\u9a8c\u53d1\u5e03\u7b49<br \/>\n&#8211; \u4e3a\u4e86\u5206\u79bb\u7279\u5b9a\u590d\u6742\u9519\u8bef\u8c03\u67e5\u800c\u8fdb\u884c\u5355\u4e2a\u529f\u80fd\u7684\u5f00\u53d1<br \/>\n&#8211; \u6bcf\u4e2a\u5206\u652f\u4ee3\u8868\u4e86\u4e0d\u540c\u64cd\u4f5c\u8005\u7684\u6210\u679c<\/p>\n<p>Git\u5c06\u50cf\u521a\u521a\u63d0\u5230\u7684\u8fd9\u6837\u7684\u5206\u652f\u79f0\u4e3a\u4e3b\u9898\u5206\u652f\u6216\u5f00\u53d1\u5206\u652f\u3002\u4e3b\u9898\u4e00\u8bcd\u53ea\u662f\u6307\u51fa\u6bcf\u4e2a\u4ed3\u5e93\u5206\u652f\u90fd\u5177\u6709\u7279\u5b9a\u7684\u76ee\u7684\u3002\u53e6\u5916\uff0cGit\u8fd8\u6709\u4e00\u4e2a\u6982\u5ff5\u53eb\u505a\u8ddf\u8e2a\u5206\u652f\uff0c\u7528\u4e8e\u540c\u6b65\u4ed3\u5e93\u7684\u526f\u672c\u3002<\/p>\n<p>\u5728\u5206\u652f\u540d\u79f0\u4e0a\u5206\u914d\u7684\u540d\u79f0\u57fa\u672c\u4e0a\u662f\u81ea\u7531\u7684\uff0c\u4f46\u6709\u4e00\u4e9b\u9650\u5236\u3002\u5b58\u50a8\u5e93\u7684\u9ed8\u8ba4\u5206\u652f\u547d\u540d\u4e3a&#8221;master&#8221;\uff0c\u5927\u591a\u6570\u5f00\u53d1\u4eba\u5458\u52aa\u529b\u5c06\u6b64\u5206\u652f\u4f5c\u4e3a\u5b58\u50a8\u5e93\u4e2d\u6700\u7a33\u5b9a\u548c\u53ef\u4fe1\u8d56\u7684\u5f00\u53d1\u7ebf\u3002\u4e3a\u4e86\u652f\u6301\u53ef\u6269\u5c55\u6027\u548c\u5206\u7c7b\u6574\u7406\uff0c\u6709\u65f6\u4f1a\u4f7f\u7528\u7c7b\u4f3cUnix\u8def\u5f84\u540d\u7684\u5c42\u6b21\u7ed3\u6784\u5206\u652f\u540d\u79f0\u3002\u4f7f\u7528\u8fd9\u79cd\u547d\u540d\u7684\u4f18\u70b9\u662fGit\u652f\u6301\u901a\u914d\u7b26\uff0c\u56e0\u6b64\u5f53\u5b58\u5728bug\/pr-1012\u6216bug\/pr-17\u7b49\u5206\u652f\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528&#8221;git show-branch &#8216;bug\/*'&#8221;\u8fdb\u884c\u76f8\u5173\u64cd\u4f5c\u3002<\/p>\n<p>\u521b\u5efa\u5206\u652f<br \/>\n\u4f7f\u7528git branch branch_name [starting-commit]\u547d\u4ee4\u6765\u521b\u5efa\u5206\u652f\u3002\u5982\u679c\u6ca1\u6709\u6307\u5b9astarting-commit\uff0c\u5c06\u4f7f\u7528\u5f53\u524d\u5206\u652f\u7684\u6700\u65b0\u63d0\u4ea4\u3002git branch\u547d\u4ee4\u53ea\u662f\u5c06\u65b0\u7684\u5206\u652f\u540d\u79f0\u5f15\u5165\u5230\u4ed3\u5e93\u4e2d\uff0c\u4e0d\u4f1a\u6539\u53d8\u5de5\u4f5c\u76ee\u5f55\u4ee5\u4f7f\u7528\u65b0\u7684\u5206\u652f\u3002<\/p>\n<p>git branch\u547d\u4ee4\u7528\u4e8e\u663e\u793a\u5b58\u50a8\u5e93\u4e2d\u627e\u5230\u7684\u5206\u652f\u5217\u8868\u3002\u8bf7\u6ce8\u610f\uff0c\u5b58\u50a8\u5e93\u4e2d\u4e0d\u4ec5\u663e\u793a\u5728\u6b64\u5904\u663e\u793a\u7684\u5206\u652f\uff0c\u8fd8\u5b58\u5728\u4e00\u79cd\u79f0\u4e3a\u8fdc\u7a0b\u8ffd\u8e2a\u5206\u652f\u7684\u5206\u652f\u3002\u5982\u679c\u60f3\u8981\u67e5\u770b\u5b83\u4eec\uff0c\u53ef\u4ee5\u4f7f\u7528-r\u9009\u9879\uff1b\u5982\u679c\u540c\u65f6\u60f3\u67e5\u770b\u4e24\u8005\uff0c\u53ef\u4ee5\u4f7f\u7528-a\u9009\u9879\u3002<\/p>\n<p>git show-branch\u547d\u4ee4\u4f1a\u663e\u793a\u6bd4git branch\u66f4\u8be6\u7ec6\u7684\u4fe1\u606f\u3002<\/p>\n<pre class=\"post-pre\"><code>* [master] add func9\r\n ! [origin\/HEAD] add func9\r\n  ! [origin\/feature-D] beta and func8\r\n   ! [origin\/master] add func9\r\n----\r\n*+ + [master] add func9\r\n*+++ [origin\/feature-D] beta and func8\r\n<\/code><\/pre>\n<p>\u4e0a\u65b9\u7684\u90e8\u5206\u4ee3\u8868\u7740\u5206\u652f\uff0c\u5e26*\u53f7\u7684\u5206\u652f\u8868\u793a\u4e3a\u5f53\u524d\u5206\u652f\u3002\u4e0b\u65b9\u7684\u90e8\u5206\u663e\u793a\u4e86\u5404\u4e2a\u5206\u652f\u4e2d\u5b58\u5728\u7684\u63d0\u4ea4\u8bb0\u5f55\u8868\u3002\u52a0\u53f7\u8868\u793a\u8be5\u63d0\u4ea4\u8bb0\u5f55\u5b58\u5728\u4e8e\u4e0a\u65b9\u5bf9\u5e94\u7684\u5206\u652f\u4e0a\uff0c\u661f\u53f7\u8868\u793a\u8be5\u63d0\u4ea4\u8bb0\u5f55\u5b58\u5728\u4e8e\u6d3b\u8dc3\u5206\u652f\u4e0a\u3002<\/p>\n<p>\u4e00\u65e6\u8fd0\u884cgit show-branch\u547d\u4ee4\u540e\uff0c\u5b83\u4f1a\u904d\u5386\u6240\u6709\u76f8\u5173\u5206\u652f\u4e0a\u7684\u6240\u6709\u63d0\u4ea4\uff0c\u76f4\u5230\u627e\u5230\u6240\u6709\u5206\u652f\u4e0a\u7684\u6700\u65b0\u5171\u540c\u63d0\u4ea4\u4e3a\u6b62\uff0c\u7136\u540e\u505c\u6b62\u663e\u793a\u5217\u8868\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4e00\u65e6\u627e\u5230\u7b2c\u4e00\u4e2a\u5171\u540c\u63d0\u4ea4\uff0c\u5c31\u4f1a\u505c\u6b62\u663e\u793a\uff0c\u4f46\u57fa\u4e8e\u7ecf\u9a8c\u6765\u8bf4\u8fd9\u662f\u5408\u7406\u7684\u3002\u4e00\u65e6\u8fbe\u5230\u8fd9\u6837\u7684\u5171\u540c\u70b9\uff0c\u6211\u4eec\u53ef\u4ee5\u63a8\u6d4b\u83b7\u5f97\u8db3\u591f\u7684\u4fe1\u606f\u6765\u7406\u89e3\u5206\u652f\u4e4b\u95f4\u7684\u5173\u8054\u3002<\/p>\n<p>git show-branch\u547d\u4ee4\u53ef\u4ee5\u63a5\u6536\u591a\u4e2a\u5206\u652f\u540d\u79f0\u4f5c\u4e3a\u53c2\u6570\u3002<\/p>\n<p>\u5207\u6362\u5230\u5206\u652f<br \/>\n\u5de5\u4f5c\u76ee\u5f55\u5728\u67d0\u4e00\u65f6\u95f4\u70b9\u53ea\u53cd\u6620\u4e00\u4e2a\u5206\u652f\u7684\u5185\u5bb9\u3002\u8981\u5f00\u59cb\u5728\u4e0d\u540c\u7684\u5206\u652f\u4e0a\u5de5\u4f5c\uff0c\u9700\u8981\u6267\u884cgit branch\u547d\u4ee4\u3002\u683c\u5f0f\u4e3agit branch \u5206\u652f\u540d\u3002<\/p>\n<p>\u5982\u679c\u5728\u63d0\u4ea4\u4e4b\u524d\u8fdb\u884c\u66f4\u6539\uff0c\u5c1d\u8bd5\u8fdb\u884c\u68c0\u51fa\u65f6\uff0c\u5c06\u88ab\u62d2\u7edd\u68c0\u51fa\u3002<\/p>\n<pre class=\"post-pre\"><code>error: Your local changes to the following files would be overwritten by checkout:\r\n    readme.md\r\nPlease commit your changes or stash them before you switch branches.\r\nAborting\r\n<\/code><\/pre>\n<p>\u5f53\u60a8\u9047\u5230\u8fd9\u4e2a\u9519\u8bef\u6d88\u606f\u65f6\uff0c\u53ef\u4ee5\u9009\u62e9\u5728\u64cd\u4f5c\u76ee\u5f55\u4e22\u5931\u5185\u5bb9\u7684\u60c5\u51b5\u4e0b\u5f3a\u5236\u8fdb\u884c\u68c0\u51fa\uff0c\u53ea\u9700\u52a0\u4e0a\u201c-f\u201d\u9009\u9879\u5373\u53ef\u3002\u8bf7\u6ce8\u610f\uff0c\u5373\u4f7f\u5df2\u7ecf\u4f7f\u7528git add\u5c06\u66f4\u6539\u6682\u5b58\uff0c\u4e5f\u53ef\u80fd\u4f1a\u51fa\u73b0\u6b64\u9519\u8bef\u3002\u56e0\u6b64\uff0c\u4e00\u79cd\u89e3\u51b3\u65b9\u6cd5\u662f\u5728\u63d0\u4ea4\u66f4\u6539\u540e\u518d\u8fdb\u884c\u68c0\u51fa\uff0c\u8fd8\u6709\u4e00\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528\u201c-m\u201d\u9009\u9879\u5c06\u66f4\u6539\u53cd\u6620\u5230\u4e0d\u540c\u7684\u5206\u652f\u3002<\/p>\n<p>\u5207\u6362\u5230bug\/pr-11\u5206\u652f<\/p>\n<p>Git\u8bd5\u56fe\u5c06\u672c\u5730\u66f4\u6539\u5e26\u5165\u65b0\u7684\u5de5\u4f5c\u76ee\u5f55\u3002\u5728\u6b64\u60c5\u51b5\u4e0b\uff0c\u5c06\u6267\u884c\u5408\u5e76\u64cd\u4f5c\uff0c\u4ee5\u5904\u7406\u672c\u5730\u66f4\u6539\u548c\u8981\u7b7e\u51fa\u7684\u5206\u652f\uff08\u4f8b\u5982\uff1abug\/pr-11\uff09\u4e4b\u95f4\u7684\u51b2\u7a81\u3002\u6b64\u65f6\uff0cGit\u4f1a\u4fee\u6539\u6587\u4ef6\u5e76\u7559\u4e0b\u8868\u793a\u5408\u5e76\u51b2\u7a81\u7684\u6807\u8bb0\u3002\u4f8b\u5982\uff0c\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<pre class=\"post-pre\"><code>++&lt;&lt;&lt;&lt;&lt;&lt;&lt; master\r\n +func10\r\n++=======\r\n+ bug_fix\r\n+ func10\r\n+ bug_pr11\r\n+ func11\r\n++&gt;&gt;&gt;&gt;&gt;&gt;&gt; local\r\n<\/code><\/pre>\n<p>\u4f5c\u4e3a\u53e6\u4e00\u79cd\u76f8\u5f53\u5e38\u89c1\u7684\u60c5\u51b5\uff0c\u6709\u65f6\u5019\u6211\u4eec\u5e0c\u671b\u5728\u521b\u5efa\u65b0\u5206\u652f\u7684\u540c\u65f6\u5207\u6362\u5230\u8be5\u5206\u652f\u3002\u4f5c\u4e3a\u4e00\u79cd\u5feb\u6377\u65b9\u6cd5\uff0c\u53ea\u9700\u5728\u547d\u4ee4\u4e2d\u52a0\u4e0a\u9009\u9879&#8221;-b new-branch&#8221;\uff08\u5176\u4e2dnew-branch\u662f\u65b0\u5206\u652f\u7684\u540d\u79f0\uff09\u3002\u5c31\u50cf\u4e4b\u524d\u4e00\u6837\uff0c\u5728\u8fdb\u884c\u6539\u52a8\u4e4b\u540e\uff0c\u53ea\u9700\u8f93\u5165\u547d\u4ee4&#8221;git checkout -b bug\/pr-7&#8243;\uff0c\u5373\u53ef\u6210\u529f\u5207\u6362\u5230\u65b0\u7684\u5206\u652f\uff0c\u800c\u65e0\u9700\u63d0\u4ea4\u6539\u52a8\u3002<\/p>\n<p>\u901a\u8fc7\u4f7f\u7528\u547d\u4ee4\u300cgit branch -d branchname\u300d\uff0c\u53ef\u4ee5\u5220\u9664\u5206\u652f\u3002\u4f46\u662f\u65e0\u6cd5\u5220\u9664\u5f53\u524d\u5206\u652f\u3002<\/p>\n<p>Git\u65e0\u6cd5\u5220\u9664\u5305\u542b\u5f53\u524d\u5206\u652f\u4e2d\u4e0d\u5b58\u5728\u7684\u63d0\u4ea4\u7684\u5206\u652f\u3002\u901a\u8fc7\u8fd9\u6837\u505a\uff0c\u53ef\u4ee5\u9632\u6b62\u65e0\u610f\u4e2d\u5220\u9664\u5305\u542b\u5728\u8981\u5220\u9664\u7684\u5206\u652f\u4e2d\u7684\u63d0\u4ea4\u7684\u6210\u679c\u7269\u3002\u5982\u679c\u8981\u5220\u9664\u7684\u5206\u652f\u5185\u5bb9\u5df2\u7ecf\u5b58\u5728\u4e8e\u5176\u4ed6\u5206\u652f\u4e0a\uff0c\u5219\u53ef\u4ee5\u5207\u6362\u5230\u8be5\u5206\u652f\u540e\u518d\u5220\u9664\u8be5\u5206\u652f\u3002<\/p>\n<p>\u5982\u679c\u4f60\u60f3\u5f3a\u5236\u5220\u9664\u4e00\u4e2a\u5206\u652f\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528git branch -D branchname\u547d\u4ee4\u3002<\/p>\n<h2>\u5173\u4e8e\u5dee\u5206(diff)\u3002<\/h2>\n<p>\u9996\u5148\uff0c\u5173\u4e8e\u666e\u901a\u7684diff\u547d\u4ee4\uff0c\u901a\u8fc7\u6dfb\u52a0-u\u9009\u9879\u53ef\u4ee5\u5f97\u5230unified diff\u683c\u5f0f\u3002<\/p>\n<p>\u4e3a\u4e86\u6bd4\u8f83\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3ainitial\u7684\u6587\u4ef6\u548c\u4e00\u4e2a\u540d\u4e3arewrite\u7684\u6587\u4ef6\u3002<\/p>\n<p>\u8fd9\u4e2a\u6587\u4ef6\u53eb\u505ainitiral\uff0c\u4f4d\u4e8e\u8fd9\u91cc\u3002<\/p>\n<pre class=\"post-pre\"><code>Now is the time\r\nFor all good men\r\nTo come to the aid\r\nOf their country\r\n<\/code><\/pre>\n<p>\u9019\u500b\u6587\u4ef6\u7684\u91cd\u65b0\u7de8\u5beb\u4f4d\u65bc\u9019\u88e1\u3002<\/p>\n<pre class=\"post-pre\"><code>Today is the time\r\nFor all good men\r\nand women\r\nTo come to the aid\r\nOf their country\r\n<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u65f6\u5019\uff0c\u666e\u901a\u7684diff\u521d\u59cb\u91cd\u5199\u547d\u4ee4\u662f<\/p>\n<pre class=\"post-pre\"><code>1c1\r\n&lt; Now is the time\r\n---\r\n&gt; Today is the time\r\n2a3\r\n&gt; and women\r\n<\/code><\/pre>\n<p>\u5c3d\u7ba1\u8868\u793a\u4e3a &#8220;-u&#8221;\uff0c\u4f46\u5e26\u6709 &#8220;-u&#8221; \u9009\u9879\u7684 diff -u initial rewrite \u547d\u4ee4<\/p>\n<pre class=\"post-pre\"><code>--- initial 2019-11-16 17:12:35.000000000 +0900\r\n+++ rewrite 2019-11-16 17:13:03.000000000 +0900\r\n@@ -1,4 +1,5 @@\r\n-Now is the time\r\n+Today is the time\r\n For all good men\r\n+and women\r\n To come to the aid\r\n Of their country\r\n<\/code><\/pre>\n<p>\u8fd9\u4e2a\u663e\u793a\u7c7b\u4f3c\u4e8e(git diff\u663e\u793a\u7684)\u3002<br \/>\n\u539f\u59cb\u6587\u4ef6\u6709 &#8212;\uff0c\u800c\u65b0\u6587\u4ef6\u6709+++\u3002<br \/>\n\u884c\u4ee5@@\u5f00\u5934\uff0c\u8868\u793a\u4e24\u4e2a\u6587\u4ef6\u7684\u884c\u53f7\u3002\u4ee5\u8d1f\u53f7\u5f00\u5934\u7684\u884c\u662f\u4ece\u539f\u59cb\u6587\u4ef6\u4e2d\u5220\u9664\u4ee5\u521b\u5efa\u65b0\u6587\u4ef6\u7684\u884c\uff0c\u4ee5\u52a0\u53f7\u5f00\u5934\u7684\u884c\u662f\u8981\u6dfb\u52a0\u7684\u884c\uff0c\u4ee5\u7a7a\u683c\u5f00\u5934\u7684\u884c\u662f\u4e24\u4e2a\u6587\u4ef6\u4e2d\u76f8\u540c\u5185\u5bb9\u7684\u90e8\u5206\u3002<\/p>\n<p>git diff\u547d\u4ee4\u53ef\u4ee5\u6267\u884c\u56db\u79cd\u57fa\u672c\u7684\u6bd4\u8f83\u64cd\u4f5c\u3002<\/p>\n<p>git diff \u4f5c\u696d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3068\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u5dee\u7570\u3092\u8868\u793a\u3059\u308b\u3002\u3053\u308c\u306f\u3001\u4f5c\u696d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u3067\u30c0\u30fc\u30c6\u30a3\u306a\u3082\u306e\u3001\u3064\u307e\u308a\u6b21\u306e\u30b3\u30df\u30c3\u30c8\u306e\u305f\u3081\u306e\u30b9\u30c6\u30fc\u30b8\u5019\u88dc\u3092\u793a\u3059\u3002<\/p>\n<p>git diff commit \u4f5c\u696d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3068\u6307\u5b9a\u3055\u308c\u305f\u30b3\u30df\u30c3\u30c8commit\u306e\u5dee\u7570\u3092\u8981\u7d04\u3057\u3066\u51fa\u529b\u3059\u308b\u3002\u3088\u304f\u3042\u308b\u306e\u306f\u3001commit\u3068\u3057\u3066HEAD\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3002<\/p>\n<p>git diff &#8211;cached commit \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u30b9\u30c6\u30fc\u30b8\u3055\u308c\u305f\u5909\u66f4\u3068\u3001\u6307\u5b9a\u3055\u308c\u305f\u30b3\u30df\u30c3\u30c8commit\u306e\u969b\u3092\u793a\u3059\u3002&#8211;staged\u3068\u3044\u3046\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u3082\u53ef\u3002\u3053\u308c\u3082commit\u306b\u306fHEAD\u304c\u3088\u304f\u6307\u5b9a\u3055\u308c\u308b\u3002<\/p>\n<p>git diff commit1 commit2 \u4efb\u610f\u306e\u4e8c\u3064\u306e\u30b3\u30df\u30c3\u30c8\u3092\u6bd4\u8f03\u3057\u305f\u3044\u6642\u306b\u3001\u3053\u306e\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u3046\u3002\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3068\u4f5c\u696d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306f\u7121\u8996\u3055\u308c\u308b\u3002<\/p>\n<p>git diff\u6709\u5f88\u591a\u9009\u9879\uff0c\u4ecb\u7ecd\u4e00\u4e9b\u6709\u7528\u7684\u9009\u9879\u3002<\/p>\n<p>-M\u30aa\u30d7\u30b7\u30e7\u30f3 \u540d\u524d\u306e\u5909\u66f4\u3092\u691c\u77e5\u3059\u308b\u3002\u30d5\u30a1\u30a4\u30eb\u306e\u524a\u9664\u3068\u305d\u308c\u306b\u7d9a\u304f\u30d5\u30a1\u30a4\u30eb\u306e\u8ffd\u52a0\u3092\u5358\u7d14\u5316\u3057\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u540d\u524d\u5909\u66f4\u3068\u3057\u3066\u51fa\u529b\u3059\u308b\u3002<\/p>\n<p>-w\u30aa\u30d7\u30b7\u30e7\u30f3(&#8211;ignore-all-space\u30aa\u30d7\u30b7\u30e7\u30f3\u3082\u540c\u3058) \u7a7a\u767d\u306e\u5909\u66f4\u3092\u7121\u8996\u3057\u3066\u6bd4\u8f03\u3059\u308b\u3002<\/p>\n<p>&#8211;stat\u30aa\u30d7\u30b7\u30e7\u30f3 2\u3064\u306e\u30c4\u30ea\u30fc\u72b6\u614b\u306e\u5dee\u5206\u306b\u95a2\u3059\u308b\u7d71\u8a08\u60c5\u5831\u3092\u51fa\u529b\u3059\u308b\u3002\u7d71\u8a08\u60c5\u5831\u3068\u3057\u3066\u306f\u3001\u5909\u66f4\u884c\u6570\u3001\u8ffd\u52a0\u884c\u6570\u3001\u524a\u9664\u884c\u6570\u304c\u7c21\u6f54\u306a\u5f62\u5f0f\u3067\u51fa\u529b\u3055\u308c\u308b\u3002\u4f8b\u3068\u3057\u3066\u306f<\/p>\n<pre class=\"post-pre\"><code>readme.md | 5 +++--\r\n 1 file changed, 3 insertions(+), 2 deletions(-)\r\n<\/code><\/pre>\n<p>\u8fd9\u4e2a\u6837\u5b50\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7git log -p\u9009\u9879\u6765\u663e\u793a\u5dee\u5f02\u3002\u4f46\u662f\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cgit log -p master..bug\/pr11\u53ea\u4f1a\u663e\u793a\u4ecemaster\u5230bug\/pr11\u7684\u63d0\u4ea4\u4e4b\u95f4\u7684\u5dee\u5f02\uff0c\u800cgit diff master..bug\/pr11\u4f1a\u5305\u542b\u5404\u4e2a\u5206\u652f\u4e0a\u5b58\u5728\u7684\u63d0\u4ea4\u5dee\u5f02\u3002<\/p>\n<p>\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\uff0c\u53ef\u4ee5\u67e5\u770b\u5728\u6587\u4ef6Documentation\/git-add.txt\u4e0a\u9650\u5b9a\u7684\u4e24\u4e2a\u63d0\u4ea4\u4e4b\u95f4\u7684\u5dee\u5f02\uff1agit diff master~5 master\u3002\u53e6\u5916\uff0c\u53ef\u4ee5\u4f7f\u7528-S&#8221;string&#8221;\u9009\u9879\u6765\u641c\u7d22\u5305\u542b\u7279\u5b9a\u5b57\u7b26\u4e32&#8221;octopus&#8221;\u7684\u63d0\u4ea4\uff0c\u4f8b\u5982git diff -S&#8221;octopus&#8221; master~50\u3002<\/p>\n<p>\u8981\u5c06\u5176\u4ed6\u5206\u652fother_branch\u5408\u5e76\u5230\u76ee\u6807\u5206\u652fbranch\u4e0a\uff0c\u9700\u8981\u5148\u68c0\u51fa\u76ee\u6807\u5206\u652fbranch\uff0c\u518d\u5c06\u5176\u4ed6\u5206\u652fother_branch\u5408\u5e76\u5230\u6b64\u5904\u3002<\/p>\n<pre class=\"post-pre\"><code>git checkout branch\r\ngit merge other_branch\r\n<\/code><\/pre>\n<p>\u5728\u5f00\u59cb\u5408\u5e76\u4e4b\u524d\uff0c\u6700\u597d\u6e05\u7406\u5de5\u4f5c\u76ee\u5f55\u3002\u5e76\u4e0d\u4e00\u5b9a\u9700\u8981\u4ee5\u6e05\u7406\u7684\u76ee\u5f55\u5f00\u59cb\uff0c\u5373\u4f7f\u5de5\u4f5c\u76ee\u5f55\u4e2d\u6563\u5e03\u7740\u4e0e\u5408\u5e76\u64cd\u4f5c\u65e0\u5173\u7684\u6587\u4ef6\uff0c\u4e5f\u53ef\u4ee5\u8fdb\u884c\u5408\u5e76\uff0c\u4f46\u57fa\u672c\u4e0a\u6e05\u7406\u662f\u66f4\u597d\u7684\u9009\u62e9\u3002<\/p>\n<h3>\u5408\u5e76\u7684\u5b9e\u9645\u4f8b\u5b50<\/h3>\n<p>\u4ee5\u4e0b\u6211\u5011\u5c07\u70ba\u5408\u4f75\u4f5c\u6e96\u5099\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nb\">mkdir <\/span>conflict\r\n<span class=\"nb\">cd <\/span>conflict\r\ngit init\r\n<span class=\"nb\">cat<\/span> <span class=\"o\">&gt;<\/span> file\r\nLine 1 stuff\r\nLine 2 stuff\r\nLine 3 stuff\r\ngit add file\r\ngit commit <span class=\"nt\">-m<\/span><span class=\"s2\">\"Initial 3 line file\"<\/span>\r\n<\/code><\/pre>\n<p>\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a&#8221;coflict&#8221;\u7684\u6587\u4ef6\u5939\uff0c\u5e76\u8fdb\u884c\u9996\u6b21\u63d0\u4ea4\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nb\">cat<\/span> <span class=\"o\">&gt;<\/span> other_file\r\nHere is stuff on another file!\r\ngit add other_file\r\ngit commit <span class=\"nt\">-m<\/span><span class=\"s2\">\"Another file\"<\/span>\r\n<\/code><\/pre>\n<p>\u5728\u4e3b\u5206\u652f\u4e0a\u8fdb\u884c\u7b2c\u4e8c\u6b21\u63d0\u4ea4\u3002<\/p>\n<pre class=\"post-pre\"><code>git checkout <span class=\"nt\">-b<\/span> alternate master^\r\ngit branch\r\ngit diff\r\ngit status\r\n<span class=\"nb\">cat<\/span> <span class=\"o\">&gt;&gt;<\/span> file\r\nLine 4 alternate stuff\r\ngit commit <span class=\"nt\">-a<\/span> <span class=\"nt\">-m<\/span><span class=\"s2\">\"Add alternate's line 4\"<\/span>\r\n<\/code><\/pre>\n<p>\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aalternate\u7684\u5206\u652f\uff0c\u4ecemaster\uff0c\u4e5f\u5c31\u662f\u5f53\u524d\u5934\u90e8\u7684\u524d\u4e00\u4e2a\u63d0\u4ea4\u8fdb\u884c\u5206\u5c90\uff0c\u5e76\u5728\u6b64\u5904\u8fdb\u884c\u63d0\u4ea4\u3002\u6b64\u65f6\u6709\u4e24\u4e2a\u5206\u652f\uff0c\u5404\u81ea\u5177\u6709\u4e0d\u540c\u7684\u6210\u679c\u7269\u3002\u8fd9\u4e24\u4e2a\u66f4\u6539\u4e0d\u4f1a\u5f71\u54cd\u540c\u4e00\u4e2a\u6587\u4ef6\u7684\u540c\u4e00\u90e8\u5206\uff0c\u56e0\u6b64\u5408\u5e76\u6ca1\u6709\u4efb\u4f55\u95ee\u9898\u3002<\/p>\n<pre class=\"post-pre\"><code>git checkout master\r\ngit merge alternate\r\ngit log <span class=\"nt\">--graph<\/span> <span class=\"nt\">--pretty<\/span><span class=\"o\">=<\/span>oneline <span class=\"nt\">--abbrev-commit<\/span>\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>*   7bd0249 (HEAD -&gt; master) Merge branch 'alternate'\r\n|\\  \r\n| * 74ac5f2 (alternate) Add alternate's line 4\r\n* | 71a8b30 Another file\r\n|\/  \r\n* 0973695 Initial 3 line file\r\n<\/code><\/pre>\n<p>\u4ee5\u8fd9\u79cd\u65b9\u5f0f\u663e\u793a\u51fa\u6765\u3002<\/p>\n<p>\u7ade\u4e89\u6027\u5408\u5e76<\/p>\n<pre class=\"post-pre\"><code>git checkout master\r\n<span class=\"nb\">cat<\/span> <span class=\"o\">&gt;&gt;<\/span> file\r\nLine 5 stuff\r\nLine 6 stuff\r\ngit commit <span class=\"nt\">-a<\/span> <span class=\"nt\">-m<\/span> <span class=\"s2\">\"Add line 5 and 6\"<\/span>\r\n<\/code><\/pre>\n<p>\u5c06\u66f4\u6539\u63d0\u4ea4\u5230\u4e3b\u5206\u652f\u3002<\/p>\n<pre class=\"post-pre\"><code>git checkout alternate\r\n<span class=\"nb\">cat<\/span> <span class=\"o\">&gt;&gt;<\/span> file\r\nLine 5 alternate stuff\r\nLine 6 alternate stuff\r\ngit commit <span class=\"nt\">-a<\/span> <span class=\"nt\">-m<\/span> <span class=\"s2\">\"Add alternate line 5 and 6\"<\/span>\r\n<\/code><\/pre>\n<p>\u4ee5\u8fd9\u6837\u7684\u65b9\u5f0f\uff0c\u5c06\u63d0\u4ea4\u5230alternate\u5206\u652f\u3002\u4e3a\u4e86\u5408\u5e76\u8fd9\u4e24\u4e2a\u5206\u652f\uff0c\u5207\u6362\u5230master\u5206\u652f\u3002<\/p>\n<pre class=\"post-pre\"><code>git checkout master\r\ngit merge alternate\r\n<\/code><\/pre>\n<p>\u5728\u8fd9\u91cc\u53d1\u751f\u4e86\u51b2\u7a81\u3002<\/p>\n<pre class=\"post-pre\"><code>Auto-merging file\r\nCONFLICT (content): Merge conflict in file\r\nAutomatic merge failed; fix conflicts and then commit the result.\r\n<\/code><\/pre>\n<p>\u5728\u8fd9\u4e00\u65f6\u70b9\u4e0a\u6267\u884cgit diff\u7684\u8bdd<\/p>\n<pre class=\"post-pre\"><code>diff --cc file\r\nindex 4d77dd1,802acf8..0000000\r\n--- a\/file\r\n+++ b\/file\r\n@@@ -2,5 -2,5 +2,10 @@@ Line 1 stuf\r\n  Line 2 stuff\r\n  Line 3 stuff\r\n  Line 4 alternate stuff\r\n++&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD\r\n +Line 5 stuff\r\n +Line 6 stuff\r\n++=======\r\n+ Line 5 alternate stuff\r\n+ Line 6 alternate stuff\r\n++&gt;&gt;&gt;&gt;&gt;&gt;&gt; alternate\r\n<\/code><\/pre>\n<p>\u7531\u4e8e\u663e\u793a\u4e86\u201c\uff0c\u6240\u4ee5\u9700\u8981\u4fee\u6539file\uff0c\u5e76\u4f7f\u7528git add file\u548cgit commit\u5c06\u5176\u6b63\u786e\u5408\u5e76\u3002<\/p>\n<p>\u5e94\u5bf9\u5408\u5e76\u51b2\u7a81<\/p>\n<p>\u4e3a\u4e86\u67e5\u770bGit\u4e3a\u5e2e\u52a9\u89e3\u51b3\u51b2\u7a81\u63d0\u4f9b\u7684\u5de5\u5177\uff0c\u521b\u5efa\u4e00\u4e2a\u7c7b\u4f3c\u7684\u5408\u5e76\u793a\u4f8b\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nb\">mkdir <\/span>conflict2\r\n<span class=\"nb\">cd <\/span>conflict2\r\ngit init\r\n<span class=\"nb\">echo <\/span>hello <span class=\"o\">&gt;<\/span> hello\r\ngit add hello\r\ngit commit <span class=\"nt\">-m<\/span><span class=\"s2\">\"Initial hello file\"<\/span>\r\ngit checkout <span class=\"nt\">-b<\/span> alt\r\n<span class=\"nb\">echo <\/span>world <span class=\"o\">&gt;&gt;<\/span> hello\r\n<span class=\"nb\">echo<\/span> <span class=\"s1\">'Yay!'<\/span> <span class=\"o\">&gt;&gt;<\/span> hello\r\ngit commit - <span class=\"nt\">-m<\/span><span class=\"s2\">\"One world\"<\/span>\r\ngit checkout master\r\n<span class=\"nb\">echo <\/span>worlds <span class=\"o\">&gt;&gt;<\/span> hello\r\n<span class=\"nb\">echo<\/span> <span class=\"s1\">'Yay!'<\/span> <span class=\"o\">&gt;&gt;<\/span> hello\r\ngit commit <span class=\"nt\">-a<\/span> <span class=\"nt\">-m<\/span><span class=\"s2\">\"All worlds\"<\/span>\r\ngit merge alt\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>Auto-merging hello\r\nCONFLICT (content): Merge conflict in hello\r\nAutomatic merge failed; fix conflicts and then commit the result.\r\n<\/code><\/pre>\n<p>Git\u4f1a\u8ddf\u8e2a\u6709\u95ee\u9898\u7684\u5355\u4e2a\u6587\u4ef6\uff0c\u5e76\u5728\u7d22\u5f15\u4e2d\u6807\u8bb0\u4e3a\u51b2\u7a81\u6216\u8005\u672a\u5408\u5e76\uff08Unmerged\uff09\u3002\u53ef\u4ee5\u4f7f\u7528git status\u547d\u4ee4\u6216git ls-files -u\u547d\u4ee4\u5728\u5de5\u4f5c\u6811\u4e2d\u663e\u793a\u672a\u5408\u5e76\u7684\u6587\u4ef6\u3002<\/p>\n<p>git \u72b6\u6001<\/p>\n<pre class=\"post-pre\"><code>On branch master\r\nYou have unmerged paths.\r\n  (fix conflicts and run \"git commit\")\r\n  (use \"git merge --abort\" to abort the merge)\r\n\r\nUnmerged paths:\r\n  (use \"git add &lt;file&gt;...\" to mark resolution)\r\n\r\n    both modified:   hello\r\n\r\nno changes added to commit (use \"git add\" and\/or \"git commit -a\")\r\n<\/code><\/pre>\n<p>git ls-files -u \u7684\u4e2d\u6587\u8fd1\u4f3c\u7ffb\u8bd1\u662f &#8220;\u5217\u51fa\u6709\u51b2\u7a81\u7684\u6587\u4ef6&#8221;\u3002<\/p>\n<pre class=\"post-pre\"><code>100644 ce013625030ba8dba906f756967f9e9ca394464a 1   hello\r\n100644 e63164d9518b1e6caf28f455ac86c8246f78ab70 2   hello\r\n100644 562080a4c6518e1bf67a9f58a32a67bff72d4f00 3   hello\r\n<\/code><\/pre>\n<p>\u53ef\u4ee5\u4f7f\u7528git diff\u6765\u663e\u793a\u672a\u5408\u5e76\u7684\u5185\u5bb9\uff0c\u4f46\u8be5\u547d\u4ee4\u4f1a\u5c06\u6bcf\u4e2a\u51b2\u7a81\u8be6\u7ec6\u5730\u663e\u793a\u51fa\u6765\u3002<\/p>\n<p>\u5f53\u7ade\u5408\u53d1\u751f\u65f6\uff0c\u6bcf\u4e2a\u7ade\u5408\u6587\u4ef6\u5728\u5176\u5de5\u4f5c\u76ee\u5f55\u4e2d\u7684\u526f\u672c\u5c06\u901a\u8fc7\u4e09\u65b9\u5dee\u5f02\u8fdb\u884c\u6807\u8bb0\u88c5\u9970\uff08\u4f7f\u7528&lt;&lt;&lt;&lt;&lt;&lt;&lt;\u548c=======\u548c&gt;&gt;&gt;&gt;&gt;&gt;&gt;\uff09\u3002<\/p>\n<p>\u55b5\u55b5\u55b5\u55b5\u55b5<\/p>\n<pre class=\"post-pre\"><code>hello\r\n&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD\r\nworlds\r\n=======\r\nworld\r\n&gt;&gt;&gt;&gt;&gt;&gt;&gt; alt\r\nYay!\r\n<\/code><\/pre>\n<p>git diff \u53ef\u4ee5\u5c06\u5de5\u4f5c\u76ee\u5f55\u4e2d\u7684\u66f4\u6539\u4e0e\u4ed3\u5e93\u4e2d\u6700\u65b0\u7248\u672c\u8fdb\u884c\u6bd4\u8f83\uff0c\u5e76\u663e\u793a\u5dee\u5f02\u4e4b\u5904\u3002<\/p>\n<pre class=\"post-pre\"><code>diff --cc hello\r\nindex e63164d,562080a..0000000\r\n--- a\/hello\r\n+++ b\/hello\r\n@@@ -1,3 -1,3 +1,7 @@@\r\n  hello\r\n++&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD\r\n +worlds\r\n++=======\r\n+ world\r\n++&gt;&gt;&gt;&gt;&gt;&gt;&gt; alt\r\n  Yay!\r\n<\/code><\/pre>\n<p>\u8fd9\u662f\u5c06\u4e24\u4e2a\u7b80\u5355\u5dee\u5f02\u5408\u5e76\u5728\u4e00\u8d77\u7684\u7ed3\u679c\u3002\u4e00\u4e2a\u5dee\u5f02\u662f\u76f8\u5bf9\u4e8eHEAD\u7684\u5dee\u5f02\uff0c\u53e6\u4e00\u4e2a\u5dee\u5f02\u662f\u76f8\u5bf9\u4e8e\u7b2c\u4e8c\u4e2a\u7236\u8282\u70b9alt\u7684\u5dee\u5f02\u3002Git\u4f1a\u7ed9\u7b2c\u4e8c\u4e2a\u7236\u8282\u70b9\u6dfb\u52a0\u4e00\u4e2a\u7279\u6b8a\u7684\u540d\u79f0MERGE_HEAD\u3002<\/p>\n<p>\u6267\u884c git diff HEAD\uff08\u6216\u8005 git diff &#8211;ours \u4e5f\u53ef\u4ee5\uff0c\u8fd9\u610f\u5473\u7740\u663e\u793a\u6211\u4eec\u7248\u672c\u4e0e\u5408\u5e76\u7248\u672c\u4e4b\u95f4\u7684\u5dee\u5f02\uff09\u3002<\/p>\n<pre class=\"post-pre\"><code>diff --git a\/hello b\/hello\r\nindex e63164d..1f2f61c 100644\r\n--- a\/hello\r\n+++ b\/hello\r\n@@ -1,3 +1,7 @@\r\n hello\r\n+&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD\r\n worlds\r\n+=======\r\n+world\r\n+&gt;&gt;&gt;&gt;&gt;&gt;&gt; alt\r\n Yay!\r\n<\/code><\/pre>\n<p>git diff MERGE_HEAD\uff08\u6216git diff &#8211;theirs\uff09\u7684\u672c\u571f\u6c49\u8bed\u91ca\u4e49\u5982\u4e0b\uff1a\u6bd4\u8f83\u5408\u5e76\u7684\u5934\u6587\u4ef6\u5dee\u5f02\uff08\u6216\u6bd4\u8f83\u4ed6\u4eec\u7684\u5dee\u5f02\uff09\u3002<\/p>\n<pre class=\"post-pre\"><code>diff --git a\/hello b\/hello\r\nindex 562080a..1f2f61c 100644\r\n--- a\/hello\r\n+++ b\/hello\r\n@@ -1,3 +1,7 @@\r\n hello\r\n+&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD\r\n+worlds\r\n+=======\r\n world\r\n+&gt;&gt;&gt;&gt;&gt;&gt;&gt; alt\r\n Yay!\r\n<\/code><\/pre>\n<p>\u5728\u8fd9\u91cc\u4fee\u6b63\u4f60\u597d\u3002<\/p>\n<pre class=\"post-pre\"><code>cat hello\r\nhello\r\n&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD\r\nworlds\r\n=======\r\nworld\r\n&gt;&gt;&gt;&gt;&gt;&gt;&gt; alt\r\nYay!\r\n<\/code><\/pre>\n<p>\u5c06\u4e0a\u9762\u7684\u5185\u5bb9\u4fee\u6539\u4e3a\u4e0b\u9762\u7684\u5185\u5bb9\uff08\u5220\u9664\u5408\u5e76\u6807\u8bb0\uff09\u3002<\/p>\n<pre class=\"post-pre\"><code>cat hello\r\nhello\r\nworldly ones\r\nYay!\r\n<\/code><\/pre>\n<p>\u7136\u540e\u67e5\u770b\u5dee\u5f02\u3002<\/p>\n<p>git diff\u53ef\u4ee5\u7528\u6765\u6bd4\u8f83\u548c\u663e\u793aGit\u4ed3\u5e93\u4e2d\u7684\u6587\u4ef6\u5dee\u5f02\u3002<\/p>\n<p>\u8fd9\u91cc\u4ec0\u4e48\u4e5f\u6ca1\u6709\u663e\u793a\uff01\uff08\u6309\u7167\u6b63\u5e38\u60c5\u51b5\u4e0b\u5e94\u8be5\u663e\u793a\u6240\u6709\u5c1a\u672a\u88ab\u5e94\u7528\u7684\u66f4\u6539\uff09<\/p>\n<p>\u5982\u679c\u4f7f\u7528git diff\u67e5\u770b\u7ade\u5408\u6587\u4ef6\uff0c\u53ea\u4f1a\u663e\u793a\u771f\u6b63\u53d1\u751f\u7ade\u5408\u7684\u90e8\u5206\u3002\u5bf9\u4e8e\u5927\u578b\u6587\u4ef6\u4e2d\u6563\u5e03\u5404\u5904\u7684\u5404\u79cd\u53d8\u66f4\uff0c\u5927\u90e8\u5206\u90fd\u4e0d\u4f1a\u53d1\u751f\u7ade\u5408\u3002\u8fd9\u662f\u56e0\u4e3a\u5408\u5e76\u5bf9\u8c61\u5206\u652f\u53ea\u6709\u4e00\u65b9\u4fee\u6539\u4e86\u8be5\u90e8\u5206\u3002\u5728\u89e3\u51b3\u7ade\u5408\u65f6\uff0c\u6211\u4eec\u4e0d\u9700\u8981\u5173\u6ce8\u8fd9\u4e9b\u90e8\u5206\u3002git diff\u57fa\u4e8e\u7b80\u5355\u7684\u7ecf\u9a8c\u6cd5\u5219\uff0c\u5254\u9664\u4e0d\u611f\u5174\u8da3\u7684\u90e8\u5206\u3002\u8be5\u7ecf\u9a8c\u6cd5\u5219\u662f\u4e0d\u663e\u793a\u53ea\u5305\u542b\u6765\u81ea\u4e00\u65b9\u7684\u53d8\u66f4\u7684\u90e8\u5206\u3002git diff\u4ecd\u7136\u53ea\u663e\u793a\u4ecd\u7136\u5b58\u5728\u7ade\u5408\u7684\u90e8\u5206\u3002<\/p>\n<p>\u5728\u7ade\u5408\u8fc7\u7a0b\u4e2d\uff0c\u8981\u51c6\u786e\u4e86\u89e3\u53d8\u66f4\u662f\u5728\u54ea\u91cc\u4ee5\u53ca\u5982\u4f55\u53d1\u751f\u7684\uff0c\u9700\u8981\u5728git log\u547d\u4ee4\u540e\u52a0\u4e0a\u7279\u5b9a\u9009\u9879\u3002\u4f7f\u7528&#8211;merge\u9009\u9879\uff0c\u53ea\u4f1a\u663e\u793a\u4e0e\u5f15\u53d1\u7ade\u5408\u7684\u6587\u4ef6\u76f8\u5173\u7684\u63d0\u4ea4\u8bb0\u5f55\u3002\u5982\u679c\u4ed3\u5e93\u5f88\u590d\u6742\u4e14\u5b58\u5728\u591a\u4e2a\u7ade\u5408\u6587\u4ef6\uff0c\u8fd8\u53ef\u4ee5\u5c06\u611f\u5174\u8da3\u7684\u6587\u4ef6\u540d\u4f5c\u4e3a\u547d\u4ee4\u884c\u53c2\u6570\u4f20\u9012\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528git log &#8211;merge hello\u6765\u5b9e\u73b0\u3002<\/p>\n<p>Git\u5982\u4f55\u51c6\u786e\u8ddf\u8e2a\u6709\u5173\u5408\u5e76\u51b2\u7a81\u7684\u6240\u6709\u4fe1\u606f\uff1f<br \/>\n&#8211; .git\/MERGE_HEAD\u5305\u542b\u5f53\u524d\u5408\u5e76\u4e2d\u7684\u63d0\u4ea4\u7684SHA1\u54c8\u5e0c\u3002<br \/>\n&#8211; .git\/MERGE_MSG\u5305\u542b\u89e3\u51b3\u51b2\u7a81\u540e\u4f7f\u7528git commit\u65f6\u7684\u9ed8\u8ba4\u5408\u5e76\u6d88\u606f\u3002<br \/>\n&#8211; Git\u7d22\u5f15\u4fdd\u5b58\u4e86\u6bcf\u4e2a\u51b2\u7a81\u6587\u4ef6\u76843\u4e2a\u526f\u672c\u3002\u8fd9\u4e09\u4e2a\u526f\u672c\u5206\u522b\u662f\u5408\u5e76\u57fa\u70b9\u3001\u6211\u4eec\u7684\u7248\u672c\u548c\u4ed6\u4eec\u7684\u7248\u672c\u3002\u8fd9\u4e09\u4e2a\u526f\u672c\u88ab\u5206\u914d\u4e86\u76f8\u5e94\u7684\u9636\u6bb5\u53f7\uff08\u5206\u522b\u662f1\u30012\u30013\uff09\uff0c\u5728git ls-files -u\u547d\u4ee4\u4e2d\u663e\u793a\u7684\u53f7\u7801\u5c31\u662f\u8fd9\u4e2a\u9636\u6bb5\u53f7\u3002\u7b80\u5355\u5730\u8bf4\uff0chello\u6587\u4ef6\u88ab\u5b58\u50a8\u4e863\u6b21\uff0c\u5e76\u4e14\u6bcf\u6b21\u90fd\u6709\u9488\u5bf93\u4e2a\u4e0d\u540c\u7248\u672c\u7684\u4e09\u4e2a\u4e0d\u540c\u54c8\u5e0c\u503c\u3002\u66f4\u8be6\u7ec6\u7684\u5185\u5bb9\u53ef\u4ee5\u4f7f\u7528git cat-file -p\u547d\u4ee4\u67e5\u770b\u3002<\/p>\n<p>git cat-file -p e63164d9 \u7684\u4e2d\u6587\u91ca\u4e49\u662f\u4ec0\u4e48\uff1f<\/p>\n<pre class=\"post-pre\"><code>hello\r\nworlds\r\nYay!\r\n<\/code><\/pre>\n<p>\u7ade\u5408\u7248\u672c\uff08\u5982\u5408\u5e76\u6807\u8bb0\u548c\u5176\u4ed6\u6240\u6709\u7248\u672c\uff09\u4e0d\u4f1a\u5b58\u50a8\u5728\u7d22\u5f15\u4e2d\uff0c\u800c\u662f\u5b58\u50a8\u5728\u5de5\u4f5c\u76ee\u5f55\u7684\u6587\u4ef6\u4e2d\u3002<\/p>\n<p>\u53ea\u8981\u6709\u51b2\u7a81\u6587\u4ef6\u5728\u7d22\u5f15\u4e2d\u8fdb\u884c\u4e86\u8bb0\u5f55\uff0c\u5c31\u9700\u8981\u5bf9\u6240\u6709\u51b2\u7a81\u6587\u4ef6\u8fdb\u884c\u67d0\u79cd\u5904\u7406\u624d\u80fd\u5408\u5e76\uff0c\u5e76\u4e14\u53ea\u8981\u5b58\u5728\u672a\u89e3\u51b3\u7684\u51b2\u7a81\uff0c\u5c31\u65e0\u6cd5\u63d0\u4ea4\u3002\u6b64\u5916\uff0c\u5982\u679c\u4fdd\u7559\u4e86\u51b2\u7a81\u6807\u8bb0\u5e76\u6267\u884cgit add\uff0c\u5219\u53ef\u4ee5\u8fdb\u884c\u63d0\u4ea4\uff0c\u4f46\u662f\u9700\u8981\u6ce8\u610f\u6587\u4ef6\u5e76\u4e0d\u5904\u4e8e\u6b63\u786e\u7684\u72b6\u6001\u3002<\/p>\n<pre class=\"post-pre\"><code>cat hello\r\nhello\r\neveryone\r\nYay!\r\ngit add hello\r\ngit ls-files -s\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>100644 ebc56522386c504db37db907882c9dbd0d05a0f0 0   hello\r\n<\/code><\/pre>\n<p>\u5728\u8fd9\u91cc\uff0cSHA1\u548c\u8def\u5f84\u4e4b\u95f4\u76840\u95f4\u9694\u8868\u793a\u6587\u4ef6\u7684\u51b2\u7a81\u72b6\u6001\u672a\u89e3\u51b3\uff0c\u5176\u9636\u6bb5\u53f7\u4e3a0\u3002<\/p>\n<p>\u732b .git\/MERGE_MSG<\/p>\n<pre class=\"post-pre\"><code>Merge branch 'alt'\r\n\r\n# Conflicts:\r\n#   hello\r\n<\/code><\/pre>\n<p>\u63d0\u4ea4 git<\/p>\n<pre class=\"post-pre\"><code>[master 199fcb8] Merge branch 'alt'\r\n<\/code><\/pre>\n<p>\u53d8\u6210\u90a3\u6837\u3002<\/p>\n<p>\u30fb\u5408\u5e76\u7684\u4e2d\u65ad\u548c\u6062\u590d<br \/>\nGit \u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u5355\u7684\u65b9\u6cd5\u6765\u4e2d\u65ad\u5408\u5e76\u64cd\u4f5c\uff0c\u4ee5\u5907\u5728\u6062\u590d\u5408\u5e76\u64cd\u4f5c\u540e\u7531\u4e8e\u67d0\u4e9b\u539f\u56e0\u4e0d\u60f3\u5b8c\u6210\u5408\u5e76\u65f6\u4f7f\u7528\u3002<\/p>\n<p>git reset &#8211;hard HEAD\u306e\u548c\u6587\u306e\u610f\u5473\u306f\u3001\u300c\u3053\u306e\u30b3\u30de\u30f3\u30c9\u306f\u3001git merge\u30b3\u30de\u30f3\u30c9\u304c\u5b9f\u884c\u3055\u308c\u308b\u524d\u306e\u72b6\u614b\u306b\u4f5c\u696d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3068\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u5373\u5ea7\u306b\u623b\u3057\u307e\u3059\u3002\u30de\u30fc\u30b8\u306e\u5b8c\u4e86\u5f8c\u307e\u305f\u306f\u30de\u30fc\u30b8\u30b3\u30df\u30c3\u30c8\u306e\u4f5c\u6210\u5f8c\u306b\u30de\u30fc\u30b8\u3092\u4e2d\u65ad\u307e\u305f\u306f\u7834\u68c4\u3059\u308b\u5834\u5408\u306f\u3001\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\u300d<\/p>\n<p>git reset &#8211;hard ORIG_HEAD\u7684\u64cd\u4f5c\u662f\u4e3a\u4e86\u4f7f\u5f97Git\u80fd\u591f\u5728\u5f00\u59cb\u5408\u5e76\u64cd\u4f5c\u524d\u4fdd\u5b58\u539f\u59cb\u5206\u652f\u7684HEAD\u4f5c\u4e3aORIG_HEAD\u3002\u901a\u8fc7\u67e5\u770b.git\/ORIG_HEAD\uff0c\u53ef\u4ee5\u53d1\u73b0\u5176\u4e2d\u5305\u542b\u7740\u4e00\u4e2a\u54c8\u5e0c\u503c\u3002\u4f46\u662f\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5982\u679c\u8fd8\u6ca1\u6709\u5728\u5e72\u51c0\u7684\u5de5\u4f5c\u76ee\u5f55\u548c\u7d22\u5f15\u4e0a\u8fdb\u884c\u8fc7\u5408\u5e76\u64cd\u4f5c\uff0c\u90a3\u4e48\u76ee\u5f55\u4e2d\u63d0\u4ea4\u7684\u4fee\u6539\u5c06\u4f1a\u4e22\u5931\u3002<\/p>\n<p>\u5728\u4e4b\u524d\u7684\u4f8b\u5b50\u4e2d\uff0c\u5206\u652f\u4e00\u822c\u53ea\u6709\u4e24\u4e2a\uff0c\u4e0d\u7b97\u592a\u590d\u6742\u3002\u4f46\u662f\u5f53\u4eba\u6570\u8d85\u8fc7\u4e09\u4eba\u4ee5\u4e0a\u65f6\uff0c\u4f1a\u6d89\u53ca\u5230\u7e41\u7410\u7684\u4ea4\u53c9\u5408\u5e76\u95ee\u9898\u3002<\/p>\n<p>\u5df2\u7ecf\u662f\u6700\u65b0\u7684\u548c\u5feb\u8fdb\u662f\u4e24\u79cd\u5e38\u89c1\u7684\u9000\u5316\u573a\u666f\u3002\u5b83\u4eec\u90fd\u4e0d\u4f1a\u5728 git \u5408\u5e76\u540e\u521b\u5efa\u65b0\u7684\u5408\u5e76\u63d0\u4ea4\u3002<\/p>\n<p>\u30fb\u5df2\u7ecf\u662f\u6700\u65b0\u72b6\u6001<\/p>\n<p>\u6267\u884c\u5408\u5e76\u540e\u7acb\u5373\u6267\u884c\u5b8c\u5168\u76f8\u540c\u7684\u5408\u5e76\u3002\u4ee5\u524d\u7684\u4f8b\u5b50\u4e2d\uff0c\u518d\u6b21\u6267\u884cgit merge alt\u3002<\/p>\n<pre class=\"post-pre\"><code>Already up to date.\r\n<\/code><\/pre>\n<p>\u88ab\u8a8d\u5b9a\u70ba\u3002<\/p>\n<p>\u5f53\u4f60\u7684\u5206\u652f\u7684HEAD\u5df2\u7ecf\u5b8c\u5168\u5b58\u5728\u4e8e\u5176\u4ed6\u5206\u652f\u4e0a\u65f6\uff0c\u5c31\u4f1a\u53d1\u751f\u5feb\u901f\u5411\u524d\u5408\u5e76\u3002\u8fd9\u4e0e\u5df2\u7ecf\u662f\u6700\u65b0\u7248\u672c\uff08already up-to-date\uff09\u6070\u6070\u76f8\u53cd\u3002\u4f8b\u5982\uff0c\u5728\u521a\u521a\u7684\u793a\u4f8b\u4e2d\uff0c\u5982\u679c\u4f60\u5c1d\u8bd5\u6267\u884cgit checkout alt\uff0c\u7136\u540e\u8fdb\u884cgit merge master\uff0c\u5feb\u901f\u5411\u524d\u5408\u5e76\u5c31\u4f1a\u53d1\u751f\u3002<\/p>\n<pre class=\"post-pre\"><code>Updating 309b43d..199fcb8\r\nFast-forward\r\n hello | 2 +-\r\n 1 file changed, 1 insertion(+), 1 deletion(-)\r\n<\/code><\/pre>\n<p>\u5f53\u8fd9\u6837\u65f6\uff0c\u4f60\u7684HEAD\u5df2\u7ecf\u5b58\u5728\u4e8e\u53e6\u4e00\u4e2a\u5206\u652f\u4e0a\uff0c\u6240\u4ee5Git\u4f1a\u7b80\u5355\u5730\u5c06\u5176\u4ed6\u5206\u652f\u7684\u63d0\u4ea4\u6dfb\u52a0\u5230\u4f60\u7684HEAD\u4e0a\uff0c\u5e76\u5c06HEAD\u79fb\u52a8\u5230\u6700\u65b0\u7684\u65b0\u63d0\u4ea4\u3002<\/p>\n<p>\u901a\u5e38\u5408\u5e76\u7b56\u7565\uff08\u89e3\u51b3\u3001\u9012\u5f52\u3001\u7ae0\u9c7c\uff09\u90fd\u4f1a\u751f\u6210\u4e00\u4e2a\u63d0\u4ea4\u5e76\u6dfb\u52a0\u5230\u5f53\u524d\u5206\u652f\u4e0a\uff0c\u8fd9\u4e2a\u63d0\u4ea4\u8868\u793a\u5408\u5e76\u540e\u7684\u72b6\u6001\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">resolve<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">resolve\u6226\u7565\u306f\u30012\u3064\u306e\u30d6\u30e9\u30f3\u30c1\u306e\u307f\u3092\u6271\u3046\u3002\u5171\u901a\u306e\u7956\u5148\u3092\u30de\u30fc\u30b8\u57fa\u70b9\u3068\u3057\u3001\u30de\u30fc\u30b8\u57fa\u70b9\u304b\u3089\u4ed6\u306e\u30d6\u30e9\u30f3\u30c1\u307e\u3067\u306e\u5909\u66f4\u3092\u30ab\u30ec\u30f3\u30c8\u30d6\u30e9\u30f3\u30c1\u306b\u9069\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u76f4\u63a53way\u30de\u30fc\u30b8\u3092\u5b9f\u884c\u3059\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">recursive<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">recursive\uff08\u518d\u5e30\uff09\u6226\u7565\u306f\u3001\u540c\u6642\u306b2\u3064\u306e\u30d6\u30e9\u30f3\u30c1\u306e\u307f\u3092\u6271\u3048\u308b\u3068\u3044\u3046\u70b9\u3067\u306f\u4e0a\u8a18\u3068\u4f3c\u3066\u3044\u308b\u3002\u3057\u304b\u3057\u3001\u518d\u5e30\u6226\u7565\u306f2\u3064\u306e\u30d6\u30e9\u30f3\u30c1\u306b2\u3064\u4ee5\u4e0a\u306e\u30de\u30fc\u30b8\u57fa\u70b9\u304c\u5b58\u5728\u3059\u308b\u3088\u3046\u306a\u5834\u5408\u3092\u6271\u3046\u3088\u3046\u306b\u8a2d\u8a08\u3055\u308c\u3066\u3044\u308b\u3002\u3053\u306e\u3088\u3046\u306a\u5834\u5408\u306b\u3001Git\u306f\u5168\u3066\u306e\u30de\u30fc\u30b8\u57fa\u70b9\u306e\u5143\u306b\u306a\u3063\u305f\u5171\u901a\u7684\u306a\u4f4d\u7f6e\u306b\u4e00\u6642\u7684\u306a\u30de\u30fc\u30b8\u3092\u4f5c\u308a\u51fa\u3057\u3001\u305d\u3053\u3092\u30de\u30fc\u30b8\u57fa\u70b9\u3068\u3057\u3066\u901a\u5e38\u306e3way\u30de\u30fc\u30b8\u30672\u3064\u306e\u30d6\u30e9\u30f3\u30c1\u306e\u6700\u7d42\u7684\u306a\u30de\u30fc\u30b8\u3092\u4f5c\u308a\u51fa\u3059\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u4f8b\u3048\u3070A\u3068B\u3068\u3044\u3046\u4e8c\u3064\u306e\u30d6\u30e9\u30f3\u30c1\u304c\u3042\u308a\u3001B\u306e\u30ce\u30fc\u30c9b\u3068A\u306e\u30ce\u30fc\u30c9a\u3092\u30de\u30fc\u30b8\u3057\u3066B\u306e\u30ce\u30fc\u30c9\u3092\u4f5c\u308b\u3002\u540c\u69d8\u306ba\u3068b\u304b\u3089A\u306e\u30ce\u30fc\u30c9\u3092\u4f5c\u308b\u3002\u3053\u306e\u6642\u4ea4\u5dee\u30de\u30fc\u30b8\u304c\u767a\u751f\u3059\u308b\u3002\u3053\u306e\u5834\u5408\u3001recursive\u6226\u7565\u3067\u306f\u3001a\u3068b\u3092\u30de\u30fc\u30b8\u3057\u3066\u4e00\u6642\u7684\u306a\u30de\u30fc\u30b8\u57fa\u70b9\u3092\u4f5c\u308a\u51fa\u3057\u3001A\u3068B\u306e\u30de\u30fc\u30b8\u57fa\u70b9\u3068\u3057\u3066\u4f7f\u3046\u3002a\u3068b\u306f\u540c\u3058\u554f\u984c\u3092\u6301\u3064\u53ef\u80fd\u6027\u304c\u3042\u308a\u3001\u3053\u308c\u3089\u3092\u30de\u30fc\u30b8\u3057\u305f\u5f8c\u3067\u3082\u3055\u3089\u306b\u53e4\u3044\u30b3\u30df\u30c3\u30c8\u3092\u30de\u30fc\u30b8\u3059\u308b\u5fc5\u8981\u304c\u51fa\u3066\u304f\u308b\u3053\u3068\u304c\u3042\u308b\u3002\u3053\u308c\u304c\u3001\u3053\u306e\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3092\u518d\u5e30\u7684\u3068\u547c\u3076\u7406\u7531\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">octopus<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">octopus\u6226\u7565\u306f\u30012\u3064\u4ee5\u4e0a\u306e\u30d6\u30e9\u30f3\u30c1\u3092\u540c\u6642\u306b\u30de\u30fc\u30b8\u3059\u308b\u305f\u3081\u306b\u8a2d\u8a08\u3055\u308c\u3066\u3044\u308b\u3002\u6982\u5ff5\u3068\u3057\u3066\u306f\u3068\u3066\u3082\u5358\u7d14\u3067\u3001recursive\u30de\u30fc\u30b8\u3092\u8907\u6570\u56de\u547c\u3073\u51fa\u3059\u3060\u3051\u3002<\/ul>\n<p>Git\u5728\u51b3\u5b9a\u91c7\u7528\u4ec0\u4e48\u6837\u7684\u7b56\u7565\u65f6\u662f\u5982\u4f55\u505a\u51fa\u51b3\u5b9a\u7684\u5462\uff1fGit\u9996\u5148\u5c1d\u8bd5\u91c7\u7528already up-to-date\u548cfast-forward\u7b56\u7565\u3002\u7136\u540e\uff0c\u5982\u679c\u9009\u62e9\u4e86\u81f3\u5c113\u4e2a\u8981\u5408\u5e76\u5230\u5f53\u524d\u5206\u652f\u7684\u5176\u4ed6\u5206\u652f\uff0c\u5219\u91c7\u7528octopus\u7b56\u7565\u3002\u8fd9\u4e2a\u7b56\u7565\u662f\u552f\u4e00\u53ef\u4ee5\u540c\u65f6\u5408\u5e763\u4e2a\u6216\u66f4\u591a\u5206\u652f\u7684\u3002\u5982\u679c\u8fd9\u79cd\u65b9\u6cd5\u4e5f\u65e0\u6548\uff0c\u5219\u91c7\u7528recursive\u7b56\u7565\u3002\u6700\u521d\uff0cGit\u91c7\u7528\u7684\u662fresolve\u7b56\u7565\uff0c\u4f46\u57282005\u5e74\u7684\u65f6\u5019\u6807\u51c6\u53d1\u751f\u4e86\u53d8\u5316\u3002\u5982\u679c\u60f3\u4f7f\u7528resolve\u7b56\u7565\uff0c\u53ef\u4ee5\u901a\u8fc7\u6307\u5b9a&#8221;git merge -s resolve branchname&#8221;\u8fd9\u6837\u7684\u65b9\u5f0f\u6765\u9009\u62e9\u3002<\/p>\n<p>\u30fb\u5408\u5e76\u9a71\u52a8\u7a0b\u5e8f<br \/>\n\u6bcf\u4e2a\u4e2a\u522b\u7684\u5408\u5e76\u7b56\u7565\uff0c\u5728\u89e3\u51b3\u6bcf\u4e2a\u6587\u4ef6\u7684\u7ade\u4e89\u4ee5\u53ca\u5408\u5e76\u64cd\u4f5c\u4e0a\u90fd\u4f7f\u7528\u4e86\u57fa\u672c\u7684\u5408\u5e76\u9a71\u52a8\u7a0b\u5e8f\u3002\u5408\u5e76\u9a71\u52a8\u7a0b\u5e8f\u63a5\u6536\u5171\u540c\u7684\u7956\u5148\u3001\u76ee\u6807\u5206\u652f\u7248\u672c\u4ee5\u53ca\u5176\u4ed6\u5206\u652f\u7248\u672c\u6240\u4ee3\u8868\u7684\u4e09\u4e2a\u4e34\u65f6\u6587\u4ef6\u540d\u3002\u9a71\u52a8\u7a0b\u5e8f\u4f1a\u4fee\u590d\u76ee\u6807\u5206\u652f\u7684\u7248\u672c\u5e76\u751f\u6210\u5408\u5e76\u7ed3\u679c\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">text\u30de\u30fc\u30b8\u30c9\u30e9\u30a4\u30d0\u306f\u3001\u901a\u5e38\u306e3way\u30de\u30fc\u30b8\u30de\u30fc\u30ab\uff08&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;\u3001=========\u3001&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;\u306e\u3053\u3068\uff09\u3092\u6b8b\u3059\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">binary\u30de\u30fc\u30b8\u30c9\u30e9\u30a4\u30d0\u306f\u3001\u5358\u7d14\u306b\u5bfe\u8c61\u30d6\u30e9\u30f3\u30c1\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u3001\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u7af6\u5408\u306e\u5370\u3092\u6b8b\u3059\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">union\u30de\u30fc\u30b8\u30c9\u30e9\u30a4\u30d0\u306f\u3001\u5358\u7d14\u306b\u53cc\u65b9\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u5168\u3066\u306e\u884c\u3092\u30de\u30fc\u30b8\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u306b\u6b8b\u3059\u3002<\/ul>\n<p>\u901a\u8fc7Git\u7684\u5c5e\u6027\u673a\u5236\uff0c\u53ef\u4ee5\u5c06\u7279\u5b9a\u7684\u6587\u4ef6\u6216\u6587\u4ef6\u6a21\u5f0f\u4e0e\u7279\u5b9a\u7684\u5408\u5e76\u9a71\u52a8\u7a0b\u5e8f\u5173\u8054\u8d77\u6765\u3002\u5927\u591a\u6570\u6587\u672c\u6587\u4ef6\u4f7f\u7528text\u9a71\u52a8\u7a0b\u5e8f\u5904\u7406\uff0c\u800c\u5927\u591a\u6570\u4e8c\u8fdb\u5236\u6587\u4ef6\u4f7f\u7528binary\u9a71\u52a8\u7a0b\u5e8f\u5904\u7406\u3002\u5bf9\u4e8e\u9700\u8981\u786e\u4fdd\u5e94\u7528\u7a0b\u5e8f\u5177\u6709\u72ec\u7279\u5408\u5e76\u64cd\u4f5c\u7684\u7279\u6b8a\u8981\u6c42\uff0c\u53ef\u4ee5\u521b\u5efa\u5e76\u6307\u5b9a\u81ea\u5b9a\u4e49\u5408\u5e76\u9a71\u52a8\u7a0b\u5e8f\u3002<\/p>\n<p>\u30fbSquash merge\uff08\u30b9\u30ab\u30c3\u30b7\u30e5\u30de\u30fc\u30b8\uff09\u306f\u3001\u307b\u3068\u3093\u3069\u306e\u30b7\u30b9\u30c6\u30e0\u3067\u306f\u3001\u3042\u308b\u30d6\u30e9\u30f3\u30c1A\u3092\u3042\u308b\u30d6\u30e9\u30f3\u30c1B\u306b\u30de\u30fc\u30b8\u3059\u308b\u969b\u306b\u30011\u3064\u306ediff\u3092\u4f5c\u6210\u3057\u3001\u5358\u72ec\u306e\u30d0\u30c3\u30c1\u3068\u3057\u3066B\u306b\u9069\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u5c65\u6b74\u306b\u65b0\u3057\u3044\u8981\u7d20\u30921\u3064\u3060\u3051\u8ffd\u52a0\u3057\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001A\u306e\u305d\u308c\u305e\u308c\u306e\u30b3\u30df\u30c3\u30c8\u304c1\u3064\u306e\u5927\u304d\u306a\u5909\u66f4\u306b\u7d71\u5408\u3055\u308c\u3001\u30b9\u30ab\u30c3\u30b7\u30e5\u30b3\u30df\u30c3\u30c8\u3068\u547c\u3070\u308c\u307e\u3059\u3002\u3057\u304b\u3057\u3001A\u306e\u5c65\u6b74\u306fB\u306e\u5c65\u6b74\u304b\u3089\u5931\u308f\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u4e00\u65b9\u3001Git\u306f\u3053\u306e\u3088\u3046\u306a\u3053\u3068\u304c\u8d77\u3053\u3089\u305a\u3001\u53cc\u65b9\u306e\u5b8c\u5168\u306a\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\u3092\u4fdd\u6301\u3057\u307e\u3059\u3002\u3082\u3057\u671b\u3080\u306a\u3089\u3001Git\u3067\u306f\u30b9\u30ab\u30c3\u30b7\u30e5\u30b3\u30df\u30c3\u30c8\u304c\u53ef\u80fd\u3067\u3042\u308a\u3001git merge\u3084git pull\u30b3\u30de\u30f3\u30c9\u306b&#8211;squash\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u63d0\u4ea4\u4fee\u6539<\/h2>\n<p>git reset\u547d\u4ee4\u5c06\u4ed3\u5e93\u548c\u5de5\u4f5c\u76ee\u5f55\u6062\u590d\u5230\u5df2\u77e5\u7684\u72b6\u6001\u3002\u8be5\u547d\u4ee4\u7684\u672c\u8d28\u662f\u5c06HEAD\u3001\u7d22\u5f15\u548c\u5de5\u4f5c\u76ee\u5f55\u6062\u590d\u4e3a\u5df2\u77e5\u72b6\u6001\u3002\u8be5\u547d\u4ee4\u6709\u4e09\u4e2a\u4e3b\u8981\u9009\u9879\u3002<\/p>\n<p>git reset &#8211;soft commit_name \u7684\u4f5c\u7528\u662f\u5c06 HEAD \u7684\u5f15\u7528\u6539\u53d8\u4e3a\u6307\u5b9a\u7684\u63d0\u4ea4\u3002\u7d22\u5f15\u548c\u5de5\u4f5c\u76ee\u5f55\u7684\u5185\u5bb9\u4e0d\u4f1a\u88ab\u66f4\u6539\u3002<\/p>\n<p>\u7528\u4e2d\u6587\u5bf9\u4ee5\u4e0b\u5185\u5bb9\u8fdb\u884c\u91ca\u4e49\uff1agit reset &#8211;mixed commit_name<br \/>\n&#8211;mixed\u9009\u9879\u4f1a\u5c06HEAD\u6307\u5411\u6307\u5b9a\u7684\u63d0\u4ea4\u3002\u7d22\u5f15\u7684\u5185\u5bb9\u4e5f\u4f1a\u6839\u636e\u8be5\u63d0\u4ea4\u8868\u793a\u7684\u6811\u7ed3\u6784\u8fdb\u884c\u66f4\u6539\uff0c\u4f46\u5de5\u4f5c\u76ee\u5f55\u7684\u5185\u5bb9\u4e0d\u4f1a\u6539\u53d8\u3002\u5728\u8fd9\u4e2a\u7248\u672c\u4e2d\uff0c\u7d22\u5f15\u4f1a\u53d8\u4e3a\u5047\u8bbe\u8be5\u63d0\u4ea4\u5305\u542b\u7684\u6240\u6709\u66f4\u6539\u90fd\u5df2\u6682\u5b58\u7684\u72b6\u6001\uff0c\u5e76\u4e14\u8fd8\u4f1a\u663e\u793a\u5bf9\u8be5\u7d22\u5f15\u800c\u8a00\u4ecd\u7559\u5728\u5de5\u4f5c\u76ee\u5f55\u4e2d\u7684\u66f4\u6539\u3002\u8fd9\u662fgit reset\u7684\u9ed8\u8ba4\u6a21\u5f0f\u3002<\/p>\n<p>git reset &#8211;hard commit_name\u547d\u4ee4\u610f\u5473\u7740\u5c06&#8211;hard\u9009\u9879\u6307\u5b9a\u7684\u63d0\u4ea4\u540d\u79f0\u8bbe\u4e3aHEAD\u7684\u5f15\u7528\uff0c\u5e76\u5c06\u7d22\u5f15\u548c\u5de5\u4f5c\u76ee\u5f55\u7684\u5185\u5bb9\u90fd\u4fee\u6539\u4e3a\u8be5\u63d0\u4ea4\u6240\u4ee3\u8868\u7684\u6811\u7684\u72b6\u6001\u3002<\/p>\n<p>git reset\u547d\u4ee4\u5c06\u539f\u59cb\u7684HEAD\u503c\u4fdd\u5b58\u5728.git\/ORIG_HEAD\u5185\u3002\u8fd9\u5728\u60f3\u8981\u4f9d\u636eHEAD\u7684\u63d0\u4ea4\u65e5\u5fd7\u6d88\u606f\u8fdb\u884c\u540e\u7eed\u63d0\u4ea4\u65f6\u975e\u5e38\u6709\u7528\u3002<\/p>\n<p>\u4e3e\u4e2agit reset\u7684\u4f8b\u5b50\u3002<\/p>\n<p>\u5047\u8bbe\u5728\u67d0\u4e2a\u76ee\u5f55\u4e0b\uff0c\u6211\u4e0d\u5c0f\u5fc3\u6267\u884c\u4e86git add foo.c\u7684\u547d\u4ee4\uff0c\u5bfc\u81f4\u5c06foo.c\u6dfb\u52a0\u5230\u4e86\u7d22\u5f15\u4e2d\u3002<\/p>\n<p>git ls-files:<\/p>\n<p>\u5217\u51fa\u5f53\u524dGit\u4ed3\u5e93\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u3002<\/p>\n<pre class=\"post-pre\"><code>main.c\r\nfoo.c\r\n<\/code><\/pre>\n<p>\u5728\u8fd9\u91cc\u6267\u884cgit reset\u3002<br \/>\ngit reset HEAD foo.c<br \/>\ngit ls-files<\/p>\n<pre class=\"post-pre\"><code>main.c\r\n<\/code><\/pre>\n<p>\u5728HEAD\u6240\u4ee3\u8868\u7684\u63d0\u4ea4\u4e2d\uff0c\u6ca1\u6709foo.c\u8fd9\u4e2a\u6587\u4ef6\u3002\u5b83\u7684\u610f\u601d\u662f&#8221;\u5bf9\u4e8e\u6587\u4ef6foo.c\uff0c\u8bf7\u5c06\u7d22\u5f15\u72b6\u6001\u8bbe\u7f6e\u4e3aHEAD\u6240\u770b\u5230\u7684\u72b6\u6001&#8221;\u3002<\/p>\n<p>\u53e6\u4e00\u4e2a\u5173\u4e8egit reset\u7684\u5e38\u89c1\u793a\u4f8b\u662f\u91cd\u65b0\u63d0\u4ea4\u6216\u79fb\u9664\u5206\u652f\u4e0a\u7684\u6700\u65b0\u63d0\u4ea4\u3002<\/p>\n<pre class=\"post-pre\"><code>git init\r\n<span class=\"nb\">echo <\/span>foo <span class=\"o\">&gt;&gt;<\/span> master_file\r\ngit add master_file\r\ngit commit <span class=\"nt\">-m<\/span><span class=\"s2\">\"Add master_file\"<\/span>\r\n<span class=\"nb\">echo<\/span> <span class=\"s2\">\"more foo\"<\/span> <span class=\"o\">&gt;&gt;<\/span> master_file\r\ngit commit master_file <span class=\"nt\">-m<\/span><span class=\"s2\">\"Add more foo\"<\/span>\r\ngit show-branch <span class=\"nt\">--more<\/span><span class=\"o\">=<\/span>5\r\n<span class=\"o\">[<\/span>master] Add more foo\r\n<span class=\"o\">[<\/span>master^] Add master_file\r\n<\/code><\/pre>\n<p>\u5047\u8bbe\u6211\u4eec\u610f\u8bc6\u5230\u7b2c\u4e8c\u6b21\u63d0\u4ea4\u9519\u8bef\uff0c\u6211\u4eec\u60f3\u91cd\u65b0\u5f00\u59cb\u3002\u8fd9\u662fgit reset &#8211;mixed HEAD^\u7684\u4e00\u4e2a\u7ecf\u5178\u793a\u4f8b\u3002<\/p>\n<p>\u5c06 git reset HEAD^ \u7ffb\u8bd1\u6210\u4e2d\u6587\u7684\u8bf4\u6cd5\uff1a\u56de\u6eda\u5230\u4e0a\u4e00\u7248\u672c<\/p>\n<pre class=\"post-pre\"><code>Unstaged changes after reset:\r\nM   master_file\r\n\r\ncat master_file\r\nfoo\r\nmore foo\r\n<\/code><\/pre>\n<p>\u6267\u884cgit reset HEAD^\u540e\uff0cGit\u4f1a\u4fdd\u7559master_file\u5728\u65b0\u7684\u72b6\u6001\u4e0b\uff0c\u5e76\u5c06\u6574\u4e2a\u5de5\u4f5c\u76ee\u5f55\u8fd8\u539f\u5230\u8fdb\u884c\u201cAdd more foo\u201d\u63d0\u4ea4\u4e4b\u524d\u3002<br \/>\n\u4f7f\u7528&#8211;mixed\u9009\u9879\u4f1a\u91cd\u7f6e\u7d22\u5f15\uff0c\u6240\u4ee5\u9700\u8981\u518d\u6b21\u5c06\u8981\u5305\u542b\u5728\u65b0\u63d0\u4ea4\u4e2d\u7684\u66f4\u6539\u8fdb\u884c\u6682\u5b58\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nb\">echo<\/span> <span class=\"s2\">\"even more foo\"<\/span> <span class=\"o\">&gt;&gt;<\/span> master_file\r\ngit commit master_file <span class=\"nt\">-m<\/span><span class=\"s2\">\"Update foo\"<\/span>\r\ngit show-branch <span class=\"nt\">--more<\/span><span class=\"o\">=<\/span>5\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>[master] Update foo\r\n[master^] Add master_file\r\n<\/code><\/pre>\n<p>\u63d0\u4ea4\u53ea\u6709\u4e24\u4e2a\u3002<\/p>\n<p>\u5728\u4e0d\u9700\u8981\u66f4\u6539\u7d22\u5f15\u7684\u60c5\u51b5\u4e0b\uff0c\u5f53\u53ea\u60f3\u4fee\u6539\u63d0\u4ea4\u6d88\u606f\u65f6\uff0c\u53ef\u4f7f\u7528\u547d\u4ee4git reset &#8211;soft HEAD^\u5e76\u642d\u914d&#8211;soft\u9009\u9879\u3002<\/p>\n<p>\u6211\u60f3\u5b8c\u5168\u5220\u9664\u7b2c\u4e8c\u4e2a\u63d0\u4ea4\uff0c\u5e76\u4e14\u4e0d\u518d\u9700\u8981\u8be5\u5185\u5bb9\u3002\u8fd9\u65f6\u53ef\u4ee5\u4f7f\u7528&#8211;hard\u9009\u9879\u3002<\/p>\n<p>\u5c06git\u91cd\u7f6e\u56de\u5230\u4e0a\u4e00\u4e2a\u63d0\u4ea4\u7684\u72b6\u6001\u3002<\/p>\n<pre class=\"post-pre\"><code>HEAD is now at cb02246 Add master_file\r\n<\/code><\/pre>\n<p>\u732b\u4e3b\u6587\u4ef6<\/p>\n<pre class=\"post-pre\"><code>foo\r\n<\/code><\/pre>\n<p>\u7531\u4e8egit reset\u539f\u5219\u4e0a\u53ef\u4ee5\u5e94\u7528\u4e8e\u5b58\u50a8\u5e93\u4e2d\u7684\u4efb\u4f55\u63d0\u4ea4\uff0c\u56e0\u6b64\u53ef\u4ee5\u6307\u5b9a\u5176\u4ed6\u5206\u652f\u7684\u63d0\u4ea4\u3002\u4f46\u662f\u8bf7\u6ce8\u610f\uff0c\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5e76\u4e0d\u4f1a\u5207\u6362\u5230\u5176\u4ed6\u5206\u652f\uff0c\u800c\u662f\u4e00\u76f4\u505c\u7559\u5728\u540c\u4e00\u4e2a\u5206\u652f\u4e0a\u3002\u4e3a\u4e86\u5c55\u793a\u4f7f\u7528git reset\u6d89\u53ca\u5176\u4ed6\u5206\u652f\u7684\u60c5\u51b5\uff0c\u6211\u4eec\u6dfb\u52a0\u4e86\u4e00\u4e2a\u540d\u4e3a&#8221;dev&#8221;\u7684\u7b2c\u4e8c\u4e2a\u5206\u652f\u3002<\/p>\n<pre class=\"post-pre\"><code>git checkout master\r\ngit checkout -b dev\r\necho bar &gt;&gt; dev_file\r\ngit commit -m\"Add dev_file to dev branch\"\r\n[dev 38fe01a] Add dev_file to dev branch\r\n 1 file changed, 1 insertion(+)\r\n create mode 100644 dev_file\r\n\r\ngit checkout master\r\ncb02246d7211c80b964bd15b5876f84a49942483\r\ngit rev-parse HEAD\r\ncb02246d7211c80b964bd15b5876f84a49942483\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>git reset --soft dev\r\ngit rev-parse HEAD\r\n38fe01a70eb10a2e1cb39974af8f5b84944512e8\r\ngit show-branch\r\n! [dev] Add dev_file to dev branch\r\n * [master] Add dev_file to dev branch\r\n--\r\n+* [dev] Add dev_file to dev branch\r\n<\/code><\/pre>\n<p>\u73b0\u5728\u5728\u4e3b\u5206\u652f\u4e0a\u5c06HEAD\u6307\u5411dev\u5206\u652f\uff08\u4f7f\u7528git reset &#8211;soft dev\u547d\u4ee4\uff09\u3002<br \/>\n\u5728\u6b64\u65f6\u63d0\u4ea4\uff0cHEAD\u6307\u5411\u5305\u542bdev_file\u7684\u63d0\u4ea4\uff0c\u4f46\u5728\u4e3b\u5206\u652f\u4e0a\u8be5\u6587\u4ef6\u4e0d\u5b58\u5728\u3002<\/p>\n<pre class=\"post-pre\"><code>echo \"Funny\" &gt; new\r\ngit add new\r\ngit commit -m \"which commit parent?\"\r\n[master 854d9dc] which commit parent?\r\n 2 files changed, 1 insertion(+), 1 deletion(-)\r\n delete mode 100644 dev_file\r\n create mode 100644 new\r\n<\/code><\/pre>\n<p>Git\u8ba4\u4e3a\u6dfb\u52a0\u4e86new\uff0c\u4f46mdev_file\u4e0d\u5305\u542b\u5728\u8fd9\u4e2a\u63d0\u4ea4\u4e2d\u3002\u7136\u800c\uff0c\u5220\u9664dev_file\u7684\u8bf4\u6cd5\u53ef\u80fd\u6709\u4e9b\u6b67\u4e49\uff0c\u56e0\u4e3a\u539f\u672c\u5b83\u5e76\u4e0d\u5b58\u5728\u4e8e\u6b64\u3002Git\u4e4b\u6240\u4ee5\u51b3\u5b9a\u5220\u9664\u8be5\u6587\u4ef6\uff0c\u662f\u56e0\u4e3a\u5728\u521b\u5efa\u65b0\u63d0\u4ea4\u65f6\uff0c\u5b83\u4f7f\u7528\u4e86HEAD\u6240\u6307\u5411\u7684\u63d0\u4ea4\u3002<\/p>\n<pre class=\"post-pre\"><code>git show-branch\r\n! [dev] Add dev_file to dev branch\r\n * [master] which commit parent?\r\n--\r\n * [master] which commit parent?\r\n+* [dev] Add dev_file to dev branch\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>git cat-file -p HEAD\r\ntree 948ed823483a0504756c2da81d2e6d8d3cd95059\r\nparent 38fe01a70eb10a2e1cb39974af8f5b84944512e8\r\nauthor ...\r\ncommitter ...\r\n\r\nwhich commit parent?\r\n<\/code><\/pre>\n<p>\u8fd9\u4e2a\u63d0\u4ea4\u7684\u7236\u63d0\u4ea4\u662f38fe01a7\uff0c\u8fd9\u662f\u5728dev\u5206\u652f\u7684\u5f00\u5934\uff0c\u4e0d\u662f\u5728master\u5206\u652f\u7684\u5f00\u5934\u3002\u73b0\u5728master\u7684\u5f00\u5934\u88ab\u4fee\u6539\u4e3a\u6307\u5411dev\u7684\u5f00\u5934\u3002\u5728\u8fd9\u4e00\u70b9\u4e0a\uff0c\u51b3\u5b9a\u8fd9\u4e2a\u6700\u65b0\u7684\u63d0\u4ea4\u662f\u5b8c\u5168\u9519\u8bef\u7684\uff0c\u5e76\u4e14\u5e94\u8be5\u88ab\u5220\u9664\u3002\u5e94\u8be5\u4f7f\u7528git reset &#8211;hard\u6765\u8fdb\u884c\u5220\u9664\u3002<\/p>\n<p>Git\u65e5\u5fd7<\/p>\n<pre class=\"post-pre\"><code>commit 854d9dc44cc9f49186325c2220a16af504a5144d (HEAD -&gt; master)\r\nAuthor: git rato &lt;hello@example.com&gt;\r\nDate:   Sun Nov 17 16:19:46 2019 +0900\r\n\r\n    which commit parent?\r\n\r\ncommit 38fe01a70eb10a2e1cb39974af8f5b84944512e8 (dev)\r\nAuthor: git taro &lt;hello@example.com&gt;\r\nDate:   Sun Nov 17 14:00:44 2019 +0900\r\n\r\n    Add dev_file to dev branch\r\n\r\ncommit cb02246d7211c80b964bd15b5876f84a49942483\r\nAuthor: git taro &lt;hello@example.com&gt;\r\nDate:   Sun Nov 17 12:02:48 2019 +0900\r\n\r\n    Add master_file\r\n<\/code><\/pre>\n<p>\u5982\u679c\u6309\u7167\u5e38\u89c4\u4f7f\u7528\uff0cHEAD^\u4ee3\u8868dev HEAD\uff0c\u56e0\u6b64\u65e0\u6cd5\u4f7f\u7528git reset &#8211;hard HEAD^\u3002<\/p>\n<p>\u83b7\u53d6git\u7684\u6700\u8fd1\u4e00\u6b21\u63d0\u4ea4\u7684\u7236\u63d0\u4ea4\u7684\u7248\u672c\u53f7\u3002<\/p>\n<pre class=\"post-pre\"><code>38fe01a70eb10a2e1cb39974af8f5b84944512e8\r\n<\/code><\/pre>\n<p>\u9664\u4e86\u4f7f\u7528 git reset &#8211;hard cb02246d7 \u8fd9\u4e2a\u65b9\u6cd5\u4e4b\u5916\uff0c\u8fd8\u6709\u5176\u4ed6\u7684\u65b9\u5f0f\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528 git reflog \u8fd9\u4e2a\u65b9\u6cd5\u3002\u5b83\u53ef\u4ee5\u663e\u793a\u51fa\u5b58\u50a8\u5e93\u4e2d\u7684\u53c2\u8003\u66f4\u6539\u5386\u53f2\u3002<\/p>\n<p>Git reflog\u2014\u83b7\u53d6\u6bcf\u4e2a HEAD \u7684\u5f15\u7528\u65e5\u5fd7\u3002<\/p>\n<pre class=\"post-pre\"><code>854d9dc (HEAD -&gt; master) HEAD@{0}: reset: moving to 854d9dc44cc9\r\n38fe01a (dev) HEAD@{1}: reset: moving to HEAD^\r\n854d9dc (HEAD -&gt; master) HEAD@{2}: commit: which commit parent?\r\n38fe01a (dev) HEAD@{3}: reset: moving to dev\r\ncb02246 HEAD@{4}: checkout: moving from dev to master\r\n38fe01a (dev) HEAD@{5}: commit: Add dev_file to dev branch\r\ncb02246 HEAD@{6}: checkout: moving from master to dev\r\ncb02246 HEAD@{7}: reset: moving to HEAD^\r\naeef304 HEAD@{8}: commit: Update foo.\r\ncb02246 HEAD@{9}: reset: moving to HEAD^\r\n3c711b8 HEAD@{10}: commit: Update foo\r\ncb02246 HEAD@{11}: reset: moving to HEAD^\r\ne1402b4 HEAD@{12}: commit: Add more foo\r\ncb02246 HEAD@{13}: commit (initial): Add master_file\r\n<\/code><\/pre>\n<p>\u6839\u636e\u8fd9\u4e2a\u4f8b\u5b50\uff0c\u7b2c5\u884c\u8bb0\u5f55\u4e86\u4ecedev\u5206\u652f\u5230master\u5206\u652f\u7684\u66f4\u6539\u3002\u5728\u90a3\u4e2a\u65f6\u5019\uff0ccb02246\u662fmaster\u7684HEAD\u3002\u56e0\u6b64\u53ef\u4ee5\u4f7f\u7528cb02246\u6216\u8005\u7b26\u53f7\u540dHEAD@{4}\u3002<\/p>\n<p>\u901a\u8fc7Git\u547d\u4ee4\u89e3\u6790HEAD@{4}\u627e\u5230\u7b2c4\u4e2a\u63d0\u4ea4<\/p>\n<pre class=\"post-pre\"><code>38fe01a70eb10a2e1cb39974af8f5b84944512e8\r\n<\/code><\/pre>\n<p>\u5c06Git\u7684\u5f53\u524d\u7248\u672c\u56de\u6eda\u5230\u524d\u56db\u4e2a\u63d0\u4ea4\u7684\u72b6\u6001\u3002<\/p>\n<pre class=\"post-pre\"><code>HEAD is now at cb02246 Add master_file\r\n<\/code><\/pre>\n<p>\u5c55\u793a\u5206\u652f\u7684Git\u547d\u4ee4\u662f\u4ec0\u4e48\uff1f<\/p>\n<pre class=\"post-pre\"><code>! [dev] Add dev_file to dev branch\r\n * [master] Add master_file\r\n--\r\n+  [dev] Add dev_file to dev branch\r\n+* [master] Add master_file\r\n<\/code><\/pre>\n<p>\u30fb\u6a31\u9009\u547d\u4ee4<br \/>\ngit\u6a31\u9009\u63d0\u4ea4\u547d\u4ee4\u662f\u5c06\u6307\u5b9a\u63d0\u4ea4commit\u6240\u5e26\u6765\u7684\u53d8\u66f4\u5e94\u7528\u4e8e\u5f53\u524d\u5206\u652f\u3002\u8be5\u547d\u4ee4\u4e0d\u4f1a\u4fee\u6539\u5b58\u50a8\u5e93\u4e2d\u7684\u73b0\u6709\u5386\u53f2\u8bb0\u5f55\uff0c\u800c\u662f\u521b\u5efa\u4e00\u4e2a\u5355\u72ec\u7684\u65b0\u63d0\u4ea4\u3002\u4e0e\u5408\u5e76\u64cd\u4f5c\u7c7b\u4f3c\uff0c\u6709\u65f6\u9700\u8981\u89e3\u51b3\u51b2\u7a81\u624d\u80fd\u5b8c\u5168\u5e94\u7528\u7531\u6307\u5b9acommit\u5e26\u6765\u7684\u53d8\u66f4\u3002<\/p>\n<p>\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u7528\u4e8e\u5c06\u5b58\u50a8\u5e93\u4e2d\u53e6\u4e00\u4e2a\u5206\u652f\u7684\u63d0\u4ea4\u5408\u5e76\u5230\u5176\u4ed6\u5206\u652f\u3002<\/p>\n<p>\u5047\u8bbe\u5728dev\u5206\u652f\u4e0a\u6709\u4e00\u7cfb\u5217\u63d0\u4ea4\uff08A\u3001B\u3001C\u3001D\u3001E\uff09\u3002\u7136\u540e\u4eceB\u5206\u652f\u884d\u751f\u51fa\u4e00\u4e2a\u540d\u4e3arel2_3\u7684\u5206\u652f\uff0c\u8be5\u5206\u652f\u4e0a\u6709\u4e00\u7cfb\u5217\u63d0\u4ea4\uff08B\u3001V\u3001W\u3001X\uff09\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u60f3\u5c06dev\u5206\u652f\u4e0aD\u5904\u4fee\u590d\u7684\u9519\u8bef\u5408\u5e76\u5230rel2_3\u5206\u652f\u4e0a\uff0c\u53ef\u4ee5\u8fdb\u884c\u4ee5\u4e0b\u64cd\u4f5c\uff1a<\/p>\n<p>\u5207\u6362\u5230rel2_3\u5206\u652f\uff0c\u6311\u9009dev\u4e4b\u524d\u7684\u63d0\u4ea4\u8fdb\u884c\u5408\u5e76\u3002<\/p>\n<p>\u901a\u8fc7\u8be5\u547d\u4ee4\uff0c\u5728rel2_3\u5206\u652f\u7684\u5f00\u5934\u521b\u5efa\u4e00\u4e2a\u5185\u5bb9\u76f8\u540c\u7684D&#8217;\u63d0\u4ea4\u3002<\/p>\n<p>\u4f5c\u4e3a\u5176\u4ed6\u901a\u7528\u7528\u9014\uff0c\u53ef\u4ee5\u9009\u62e9\u4e00\u4e2a\u5206\u652f\u7684\u63d0\u4ea4\uff0c\u5e76\u5c06\u5176\u5e94\u7528\u5230\u65b0\u5206\u652f\u4e0a\uff0c\u4ece\u800c\u91cd\u5efa\u4e00\u7cfb\u5217\u7684\u63d0\u4ea4\u3002\u4ee5\u4e0b\u662f\u5728my_dev\u5206\u652f\u4e0a\u91cd\u65b0\u6784\u5efa\u591a\u4e2a\u63d0\u4ea4\u5e76\u5e94\u7528\u5230master\u5206\u652f\u7684\u793a\u4f8b\u3002<\/p>\n<pre class=\"post-pre\"><code>git checkout master\r\ngit cherry-pick my_dev~\r\ngit cherry-pick my_dev~3\r\ngit cherry-pick my_dev~2\r\ngit cherry-pick my_dev\r\n<\/code><\/pre>\n<p>\u53ef\u4ee5\u6309\u7167\u81ea\u5df1\u559c\u6b22\u7684\u987a\u5e8f\u5c06\u559c\u6b22\u7684\u63d0\u4ea4\u6392\u5217\u5728\u4e3b\u5206\u652f\u4e2d\u3002<\/p>\n<p>git revert\u547d\u4ee4\u4e0egit cherry-pick\u547d\u4ee4\u76f8\u4f3c\uff0c\u4f46\u6709\u4e00\u4e2a\u91cd\u8981\u7684\u533a\u522b\u3002\u8be5\u547d\u4ee4\u4f1a\u5e94\u7528\u4e0e\u6307\u5b9a\u7684\u63d0\u4ea4commit\u76f8\u53cd\u7684\u53d8\u5316\uff0c\u4e5f\u5c31\u662f\u5f15\u5165\u4e00\u4e2a\u65b0\u7684\u63d0\u4ea4\u6765\u64a4\u9500\u6307\u5b9a\u63d0\u4ea4\u7684\u6548\u679c\u3002\u4e0echerry-pick\u4e00\u6837\uff0c\u5b83\u4e0d\u4f1a\u4fee\u6539\u5b58\u50a8\u5e93\u4e2d\u7684\u73b0\u6709\u5386\u53f2\u8bb0\u5f55\u3002<\/p>\n<p>\u30fbreset\u3001revert\u3001checkout\u547d\u4ee4\u7684\u533a\u522b<br \/>\n\u8fd9\u4e09\u4e2a\u6307\u4ee4\u53ef\u80fd\u4f1a\u5f15\u8d77\u6df7\u6dc6\u3002\u5b83\u4eec\u770b\u8d77\u6765\u90fd\u6267\u884c\u76f8\u540c\u7684\u64cd\u4f5c\uff0c\u5e76\u4e14\u5728\u5176\u4ed6\u7248\u672c\u7ba1\u7406\u7cfb\u7edf\u4e2d\uff0creset\u3001revert\u3001checkout\u5177\u6709\u4e0d\u540c\u7684\u542b\u4e49\u3002\u5173\u4e8e\u4f55\u65f6\u4f7f\u7528\u548c\u4e0d\u4f7f\u7528\u8fd9\u4e9b\u6307\u4ee4\uff0c\u6709\u4e00\u4e9b\u6307\u5bfc\u539f\u5219\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u7570\u306a\u308b\u30d6\u30e9\u30f3\u30c1\u306b\u79fb\u884c\u3057\u305f\u3044\u306a\u3089git checkout\u3092\u4f7f\u3046\u3079\u304d\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>git reset\u30b3\u30de\u30f3\u30c9\u3067\u306f\u30d6\u30e9\u30f3\u30c1\u3092\u79fb\u52d5\u3057\u306a\u3044\u3002git reset\u306f\u30ab\u30ec\u30f3\u30c8\u30d6\u30e9\u30f3\u30c1\u306eHEAD\u53c2\u7167\u3092\u30ea\u30bb\u30c3\u30c8\u3059\u308b\u3053\u3068\u3092\u76ee\u7684\u3068\u3057\u3066\u3044\u308b\u3002<\/p>\n<p>git reset &#8211;hard\u306f\u65e2\u77e5\u306e\u72b6\u614b\u3092\u5fa9\u5143\u3059\u308b\u3088\u3046\u306b\u8a2d\u8a08\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u5931\u6557\u3057\u305f\u30de\u30fc\u30b8\u3092\u5143\u306b\u623b\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u304c\u3001git checkout\u306f\u305d\u3046\u306f\u306a\u3089\u306a\u3044\u3002<\/p>\n<p>git checkout\u5f15\u53d1\u7684\u6df7\u4e71\u662f\u7531\u4e8e\u5176\u989d\u5916\u7684\u80fd\u529b\uff0c\u5373\u4ece\u5bf9\u8c61\u5b58\u50a8\u533a\u4e2d\u53d6\u51fa\u6587\u4ef6\u5e76\u653e\u7f6e\u5230\u5de5\u4f5c\u76ee\u5f55\u4e2d\uff0c\u4ee5\u53ca\u66ff\u6362\u5de5\u4f5c\u76ee\u5f55\u4e2d\u7684\u7248\u672c\u3002\u8be5\u6587\u4ef6\u7684\u7248\u672c\u53ef\u80fd\u662f\u5f53\u524d\u7684HEAD\u7248\u672c\uff0c\u4e5f\u53ef\u80fd\u662f\u4e4b\u524d\u7684\u7248\u672c\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"c\"># \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u304b\u3089file.c\u3092\u30c1\u30a7\u30c3\u30af\u30a2\u30a6\u30c8<\/span>\r\ngit checkout <span class=\"nt\">--<\/span> path\/to\/file.c\r\n\r\n<span class=\"c\"># \u30ea\u30d3\u30b8\u30e7\u30f3v2.3\u304b\u3089file.c\u3092\u30c1\u30a7\u30c3\u30af\u30a2\u30a6\u30c8<\/span>\r\ngit checkout v2.3 <span class=\"nt\">--<\/span> some\/file.c\r\n<\/code><\/pre>\n<p>Git\u4f1a\u79f0\u4e4b\u4e3a\u8def\u5f84\u7684\u68c0\u51fa\u3002<\/p>\n<p>\u5728\u524d\u4e00\u79cd\u60c5\u51b5\u4e0b\uff0c\u4ece\u5bf9\u8c61\u5b58\u50a8\u533a\u83b7\u53d6\u5f53\u524d\u7248\u672c\u7684\u64cd\u4f5c\u770b\u8d77\u6765\u7c7b\u4f3c\u4e8e\u91cd\u7f6e\u64cd\u4f5c\u3002\u4fee\u6539\u672c\u5730\u5de5\u4f5c\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\u5c06\u88ab\u653e\u5f03\uff0c\u5e76\u88ab\u201c\u91cd\u7f6e\u201d\u4e3a\u5f53\u524d\u7684HEAD\u7248\u672c\u3002<\/p>\n<p>\u5728\u540e\u4e00\u79cd\u60c5\u51b5\u4e0b\uff0c\u5c06\u4ece\u5bf9\u8c61\u5b58\u50a8\u533a\u4e2d\u63d0\u53d6\u6587\u4ef6\u7684\u5148\u524d\u7248\u672c\uff0c\u5e76\u5c06\u5176\u653e\u7f6e\u5728\u5de5\u4f5c\u76ee\u5f55\u4e2d\u3002\u8fd9\u770b\u8d77\u6765\u50cf\u662f\u5bf9\u8be5\u6587\u4ef6\u7684\u201c\u64a4\u9500\u201d\u64cd\u4f5c\u3002<\/p>\n<p>\u8fd9\u4e24\u79cd\u64cd\u4f5c\u90fd\u4e0d\u80fd\u88ab\u89c6\u4e3agit reset\u6216git revert\u3002\u4e24\u79cd\u60c5\u51b5\u4e0b\u6587\u4ef6\u90fd\u662f\u4ece\u7279\u5b9a\u63d0\u4ea4\u7684HEAD\u548cv2.3\u4e2d\u201c\u68c0\u51fa\u201d\u7684\u3002git revert\u547d\u4ee4\u662f\u5bf9\u6574\u4e2a\u63d0\u4ea4\u8fdb\u884c\u64cd\u4f5c\uff0c\u800c\u4e0d\u662f\u9488\u5bf9\u6587\u4ef6\u7684\u64cd\u4f5c\u3002<\/p>\n<p>\u5f53\u5176\u4ed6\u5f00\u53d1\u8005\u514b\u9686\u4e86\u60a8\u7684\u5b58\u50a8\u5e93\u6216\u63d0\u53d6\u4e86\u4e00\u4e9b\u63d0\u4ea4\u65f6\uff0c\u4e0e\u63d0\u4ea4\u5386\u53f2\u7684\u66f4\u6539\u5bc6\u5207\u76f8\u5173\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u60a8\u4e0d\u5e94\u8be5\u4f7f\u7528\u6539\u53d8\u5b58\u50a8\u5e93\u5386\u53f2\u8bb0\u5f55\u7684\u547d\u4ee4\u3002\u800c\u5e94\u8be5\u4f7f\u7528git revert\u547d\u4ee4\u3002\u4e5f\u4e0d\u5e94\u8be5\u4f7f\u7528git reset\u6216git commit &#8211;amend\u547d\u4ee4\u3002<\/p>\n<p>\u30fb\u4fee\u6539\u9996\u6b21\u63d0\u4ea4<br \/>\n\u5728\u5f53\u524d\u5206\u652f\u4e2d\u4fee\u6539\u6700\u65b0\u63d0\u4ea4\u7684\u6700\u7b80\u5355\u65b9\u6cd5\u4e4b\u4e00\u662f\u4f7f\u7528git commit &#8211;amend\u3002\u4e00\u822c\u6765\u8bf4\uff0camend\u8868\u793a\u63d0\u4ea4\u57fa\u672c\u4e0a\u5177\u6709\u76f8\u540c\u7684\u5185\u5bb9\uff0c\u4f46\u8fd8\u9700\u8981\u505a\u4e00\u4e9b\u8c03\u6574\u3002\u5b83\u7ecf\u5e38\u7528\u4e8e\u5728\u63d0\u4ea4\u540e\u4fee\u6b63\u62fc\u5199\u9519\u8bef\uff0c\u4f46\u4e0e\u666e\u901a\u63d0\u4ea4\u4e00\u6837\uff0c\u4e5f\u53ef\u4ee5\u4fee\u6539\u5b58\u50a8\u5e93\u4e2d\u7684\u4efb\u4f55\u6587\u4ef6\uff0c\u5e76\u53ef\u4ee5\u6dfb\u52a0\u6216\u5220\u9664\u6587\u4ef6\u3002git commit &#8211;amend\u51c6\u5907\u4fee\u590d\u63d0\u4ea4\u6d88\u606f\u65f6\uff0c\u4f1a\u50cf\u666e\u901a\u7684git commit\u547d\u4ee4\u4e00\u6837\u542f\u52a8\u7f16\u8f91\u5668\u5e76\u63d0\u793a\u7528\u6237\u8f93\u5165\u6d88\u606f\u3002<\/p>\n<h2>\u63d0\u4ea4\u91cd\u6574<\/h2>\n<p>git rebase \u547d\u4ee4\u7528\u4e8e\u5728\u4fee\u6539\u4e00\u7cfb\u5217\u63d0\u4ea4\u7684\u57fa\u70b9\u65f6\u4f7f\u7528\u3002\u5b83\u7684\u666e\u904d\u5e94\u7528\u662f\u5c06\u4f60\u5f00\u53d1\u7684\u4e00\u7cfb\u5217\u63d0\u4ea4\u4fdd\u6301\u4e3a\u6700\u65b0\u72b6\u6001\uff0c\u76f8\u5bf9\u4e8e\u5176\u4ed6\u5206\u652f\u3002\u5176\u4ed6\u5206\u652f\u901a\u5e38\u6307\u7684\u662f\u4e3b\u5206\u652f\u6216\u6765\u81ea\u5176\u4ed6\u4ed3\u5e93\u7684\u8ffd\u8e2a\u5206\u652f\u3002<\/p>\n<p>\u5047\u8bbe\u6709\u4e24\u4e2a\u5206\u652f\uff1a\u4e3b\u5206\u652f(master)\u548c\u4e3b\u9898\u5206\u652f(topic)\u3002\u4e3b\u5206\u652f(master)\u5305\u542bA\u3001B\u3001C\u3001D\u3001E\u8fd9\u4e9b\u63d0\u4ea4\uff0c\u800c\u4e3b\u9898\u5206\u652f(topic)\u5305\u542bB\u3001W\u3001X\u3001Y\u3001Z\u8fd9\u4e9b\u63d0\u4ea4\u3002\u901a\u8fc7\u5c06\u4e00\u7cfb\u5217\u63d0\u4ea4\u7684\u57fa\u70b9\u4ece\u63d0\u4ea4B\u66f4\u6539\u4e3a\u63d0\u4ea4E\uff0c\u53ef\u4ee5\u4f7f\u4e3b\u5206\u652f(master)\u4fdd\u6301\u6700\u65b0\u7684\u72b6\u6001\u3002<\/p>\n<pre class=\"post-pre\"><code>git checkout topic\r\ngit rebase master\r\n<\/code><\/pre>\n<p>\u6216\u8005<\/p>\n<p>\u5c06\u4e3b\u5206\u652f\uff08master\uff09\u5408\u5e76\u81f3\u4e3b\u9898\u5206\u652f\uff08topic\uff09<\/p>\n<p>\u901a\u8fc7\u8fd9\u4e2a\u64cd\u4f5c\uff0c\u4e3b\u5206\u652f\u4fdd\u6301\u4e0d\u53d8\uff0c\u4ecd\u7136\u662fA\u3001B\u3001C\u3001D\u3001E\uff0c\u4f46\u662f\u8bdd\u9898\u5206\u652f\u4ece\u4e3b\u5206\u652f\u7684\u6700\u540e\u4e00\u70b9E\u5f00\u59cb\u53d8\u6210\u4e86E\u3001W&#8217;\u3001X&#8217;\u3001Y&#8217;\u3001Z&#8217;\u3002\u8fd9\u88ab\u79f0\u4e3a\u524d\u5411\u79fb\u690d\uff08forward-port\uff09\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u8bdd\u9898\u5206\u652f\u88ab\u79fb\u690d\u5230\u4e86\u4e3b\u5206\u652f\u7684\u524d\u65b9\uff0crebase\u547d\u4ee4\u4e5f\u53ef\u4ee5\u5b9e\u73b0\u540e\u5411\u79fb\u690d\uff08back-port\uff09\u3002<\/p>\n<p>\u540c\u6837\uff0cgit rebase\u547d\u4ee4\u4e5f\u53ef\u4ee5\u7528\u4e8e\u5c06\u4e00\u4e2a\u5f00\u53d1\u5206\u652f\u5b8c\u5168\u79fb\u690d\u5230\u4e00\u4e2a\u5b8c\u5168\u4e0d\u540c\u7684\u5206\u652f\u4e0a\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u6dfb\u52a0&#8211;onto\u547d\u4ee4\u3002<\/p>\n<p>\u4e00\u65e6\u53d1\u73b0\u51b2\u7a81\uff0c\u56de\u6eaf\u64cd\u4f5c\u5c06\u6682\u505c\uff0c\u76f4\u5230\u51b2\u7a81\u89e3\u51b3\u4e3a\u6b62\u3002\u4e00\u65e6\u89e3\u51b3\u4e86\u51b2\u7a81\uff0c\u5e76\u5728\u89e3\u51b3\u7684\u7ed3\u679c\u4e0a\u66f4\u65b0\u4e86\u7d22\u5f15\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528git rebase &#8211;continue\u547d\u4ee4\u6765\u6062\u590d\u91cd\u65b0\u64cd\u4f5c\u3002\u8be5\u547d\u4ee4\u4f1a\u5c06\u89e3\u51b3\u7684\u51b2\u7a81\u63d0\u4ea4\u5e76\u7ee7\u7eed\u64cd\u4f5c\uff0c\u5c06\u4e00\u7cfb\u5217\u5f85\u91cd\u65b0\u57fa\u4e8e\u7684\u63d0\u4ea4\u524d\u8fdb\u81f3\u4e0b\u4e00\u4e2a\u3002<br \/>\n\u5728\u68c0\u67e5\u4e86\u57fa\u4e8e\u7684\u51b2\u7a81\u540e\uff0c\u5982\u679c\u51b3\u5b9a\u67d0\u4e2a\u7279\u5b9a\u63d0\u4ea4\u4e0d\u518d\u9700\u8981\uff0c\u53ef\u4ee5\u4f7f\u7528git rebase &#8211;skip\u6765\u8df3\u8fc7\u8be5\u63d0\u4ea4\uff0c\u5e76\u7ee7\u7eed\u8fdb\u884c\u4e0b\u4e00\u4e2a\u63d0\u4ea4\u3002<br \/>\n\u5982\u679c\u610f\u8bc6\u5230\u91cd\u65b0\u57fa\u4e8e\u64cd\u4f5c\u5b8c\u5168\u9519\u8bef\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528git rebase &#8211;abort\u6765\u653e\u5f03\u64cd\u4f5c\uff0c\u5e76\u5c06\u4ed3\u5e93\u6062\u590d\u5230\u539f\u6765\u7684git rebase\u4e4b\u524d\u7684\u72b6\u6001\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u5f53\u50cf\u521a\u624d\u7684\u4f8b\u5b50\u4e00\u6837\u5c06\u4e24\u6761\u76f4\u7ebf\u7684\u5206\u652f\u8fdb\u884crebase\u65f6\u662f\u5f88\u597d\u7684\uff0c\u4f46\u662f\u5f53\u6709\u5176\u4ed6\u4ee5\u81ea\u5df1\u7684\u5206\u652f\u5185\u90e8\u4e3a\u8d77\u70b9\u7684\u5206\u652f\u65f6\u5c31\u8981\u5c0f\u5fc3\u4e86\u3002\u5982\u679c\u60f3\u8981rebase\u6574\u4e2a\u5305\u542b\u5b50\u5206\u652f\u7684\u5206\u652f\u65f6\uff0c\u8bf7\u4f7f\u7528&#8211;preserbe-merge\u9009\u9879\u3002<br \/>\n\u6b64\u5916\uff0c\u5bf9\u4e8e\u5305\u542b\u5408\u5e76\u7684\u5206\u652f\u8fdb\u884crebase\u4e5f\u5f88\u5bb9\u6613\u5bfc\u81f4\u6df7\u4e71\uff0c\u6240\u4ee5\u8981\u5c0f\u5fc3\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30ea\u30d9\u30fc\u30b9\u306f\u65e2\u5b58\u306e\u30b3\u30df\u30c3\u30c8\u3092\u66f8\u304d\u63db\u3048\u3066\u3001\u65b0\u3057\u3044\u30b3\u30df\u30c3\u30c8\u3092\u4f5c\u308b<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u5230\u9054\u4e0d\u53ef\u80fd\u306b\u306a\u3063\u305f\u53e4\u3044\u30b3\u30df\u30c3\u30c8\u306f\u524a\u9664\u3055\u308c\u308b<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30ea\u30d9\u30fc\u30b9\u524d\u306e\u53e4\u3044\u30b3\u30df\u30c3\u30c8\u306e\u30e6\u30fc\u30b6\u30fc\u306f\u53d6\u308a\u6b8b\u3055\u308c\u3066\u3057\u307e\u3046<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30ea\u30d9\u30fc\u30b9\u524d\u306e\u30b3\u30df\u30c3\u30c8\u3092\u4f7f\u3063\u3066\u3044\u308b\u30d6\u30e9\u30f3\u30c1\u304c\u3042\u308b\u306a\u3089\u3001\u305d\u308c\u3082\u540c\u69d8\u306b\u30ea\u30d9\u30fc\u30b9\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u304b\u3082\u3057\u308c\u306a\u3044<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u7570\u306a\u308b\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u30ea\u30d9\u30fc\u30b9\u524d\u30b3\u30df\u30c3\u30c8\u306e\u30e6\u30fc\u30b6\u30fc\u304c\u3044\u308b\u5834\u5408\u3001\u3042\u306a\u305f\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u3067\u306f\u3059\u3067\u306b\u79fb\u52d5\u6e08\u307f\u3060\u3068\u3057\u3066\u3082\u3001\u305d\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u306f\u30b3\u30df\u30c3\u30c8\u306e\u30b3\u30d4\u30fc\u304c\u6b8b\u3063\u305f\u307e\u307e\u3067\u3059\u3002\u3053\u306e\u305f\u3081\u3001\u5f7c\u3089\u3082\u540c\u69d8\u306b\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\u3092\u4fee\u6b63\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u304f\u306a\u308b\u308d\u3046<\/ul>\n<h3>git rebase -i\u7684\u5b9e\u9645\u4f8b\u5b50<\/h3>\n<p>\u521b\u5efa\u4e00\u4e2a\u4f7f\u7528&#8221;git rebase -i&#8221;\u7684\u793a\u4f8b\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nb\">mkdir <\/span>haiku\r\n<span class=\"nb\">cd <\/span>haiku\r\ngit init\r\n<span class=\"nb\">cat <\/span>haiku\r\nTalk about colour\r\nNo jealous behaviour here\r\ngit add haiku\r\ngit commit <span class=\"nt\">-m<\/span><span class=\"s2\">\"Start my haiku\"<\/span>\r\n<\/code><\/pre>\n<p>\u6211\u66fe\u5199\u4e86\u4e00\u9996\u4ff3\u53e5\uff0c\u5c06color\u7684\u62fc\u5199\u6539\u4e3acolor\u3002<\/p>\n<pre class=\"post-pre\"><code>git diff\r\ndiff --git a\/haiku b\/haiku\r\nindex 088bea0..958aff0 100644\r\n--- a\/haiku\r\n+++ b\/haiku\r\n@@ -1,2 +1,2 @@\r\n-Talk about colour\r\n+Talk about color\r\n No jealous behaviour here\r\n\r\ngit commit -a -m \"use color instead of colour\"\r\n<\/code><\/pre>\n<p>\u6dfb\u52a0\u4ff3\u53e5\u4ee5\u5b8c\u6210\u3002<\/p>\n<pre class=\"post-pre\"><code>echo I favour red wine &gt;&gt; haiku\r\ngit diff\r\ndiff --git a\/haiku b\/haiku\r\nindex 958aff0..cdeddf9 100644\r\n--- a\/haiku\r\n+++ b\/haiku\r\n@@ -1,2 +1,3 @@\r\n Talk about color\r\n No jealous behaviour here\r\n+I favour red wine\r\n\r\ngit commit -a -m \"Finish my colour haiku\"\r\n<\/code><\/pre>\n<p>\u5728\u8fd9\u91cc\uff0c\u6839\u636e\u62fc\u5199\u518d\u6b21\u8ff7\u60d1\uff0c\u5728\u5c06\u82f1\u56fd\u5f0f\u7684&#8221;ou&#8221;\u6539\u4e3a\u7f8e\u56fd\u5f0f\u7684&#8221;o&#8221;\u3002<\/p>\n<pre class=\"post-pre\"><code>git diff\r\ndiff --git a\/haiku b\/haiku\r\nindex cdeddf9..064c1b5 100644\r\n--- a\/haiku\r\n+++ b\/haiku\r\n@@ -1,3 +1,3 @@\r\n Talk about color\r\n-No jealous behaviour here\r\n-I favour red wine\r\n+No jealous behavior here\r\n+I favor red wine\r\n\r\ngit commit -a -m\"Use American spellings\"\r\n<\/code><\/pre>\n<p>\u6700\u7ec8\u63d0\u4ea4\u5386\u53f2\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<p>\u663e\u793a4\u4e2a\u66f4\u591a\u7684\u5206\u652f\u3002<\/p>\n<p>(Translation: Display four more branches.)<\/p>\n<pre class=\"post-pre\"><code>[master] Use American spellings\r\n[master^] Finish my colour haiku\r\n[master~2] use color instead of colour\r\n[master~3] Start my haiku\r\n<\/code><\/pre>\n<p>\u5047\u8bbe\u6211\u5e0c\u671b\u5728\u8fd9\u91cc\u5c06\u63d0\u4ea4\u5386\u53f2\u4ee5\u4ff3\u53e5\u7684\u5f62\u5f0f\u5b8c\u6210\u2192\u4fee\u6b63\u62fc\u5199\u7684\u65b9\u5f0f\u5448\u73b0\u3002<\/p>\n<pre class=\"post-pre\"><code>[master] Use American spellings\r\n[master^] use color instead of colour\r\n[master~2] Finish my colour haiku\r\n[master~3] Start my haiku\r\n<\/code><\/pre>\n<p>\u5982\u679c\u6709\u4e24\u4e2a\u4fee\u6b63\u5355\u8bcd\u62fc\u5199\u7684\u63d0\u4ea4\u8bb0\u5f55\uff0c\u6211\u8ba4\u4e3a\u8fd9\u662f\u4e0d\u597d\u7684\u3002\u6240\u4ee5\u6211\u60f3\u5c06master\u548cmaster^\u5408\u5e76\u4e3a\u4e00\u4e2a\u63d0\u4ea4\u3002<\/p>\n<pre class=\"post-pre\"><code>[master] Use American spellings\r\n[master^] Finish my colour haiku\r\n[master~2] Start my haiku\r\n<\/code><\/pre>\n<p>\u901a\u8fc7\u6dfb\u52a0-i\u6216&#8211;interactive\u9009\u9879\uff0c\u53ef\u4ee5\u4f7f\u7528git rebase\u547d\u4ee4\u6765\u91cd\u65b0\u6392\u5e8f\u3001\u7f16\u8f91\u3001\u5220\u9664\u63d0\u4ea4\u3001\u5c06\u591a\u4e2a\u63d0\u4ea4\u538b\u7f29\u4e3a\u4e00\u4e2a\u63d0\u4ea4\u3001\u5c06\u4e00\u4e2a\u63d0\u4ea4\u62c6\u5206\u4e3a\u591a\u4e2a\u63d0\u4ea4\u3002<\/p>\n<pre class=\"post-pre\"><code>pick 002a668 Finish my colour haiku\r\npick 1431447 Use American spellings\r\n\r\n# Rebase 505057b..1431447 onto 505057b (3 commands)\r\n#\r\n# Commands:\r\n# p, pick &lt;commit&gt; = use commit\r\n# r, reword &lt;commit&gt; = use commit, but edit the commit message\r\n# e, edit &lt;commit&gt; = use commit, but stop for amending\r\n# s, squash &lt;commit&gt; = use commit, but meld into previous commit\r\n# f, fixup &lt;commit&gt; = like \"squash\", but discard this commit's log message\r\n# x, exec &lt;command&gt; = run command (the rest of the line) using shell\r\n# b, break = stop here (continue rebase later with 'git rebase --continue')\r\n# d, drop &lt;commit&gt; = remove commit\r\n# l, label &lt;label&gt; = label current HEAD with a name\r\n# t, reset &lt;label&gt; = reset HEAD to a label\r\n# m, merge [-C &lt;commit&gt; | -c &lt;commit&gt;] &lt;label&gt; [# &lt;oneline&gt;]\r\n# .       create a merge commit using the original merge commit's\r\n# .       message (or the oneline, if no original merge commit was\r\n# .       specified). Use -c &lt;commit&gt; to reword the commit message.\r\n#\r\n# These lines can be re-ordered; they are executed from top to bottom.\r\n#\r\n# If you remove a line here THAT COMMIT WILL BE LOST.\r\n#\r\n# However, if you remove everything, the rebase will be aborted.\r\n#\r\n# Note that empty commits are commented out\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>pick 002a668 Finish my colour haiku\r\npick d36a1d4 use color instead of colour\r\npick 1431447 Use American spellings\r\n<\/code><\/pre>\n<p>\u6309\u7167\u987a\u5e8f\u91cd\u65b0\u6392\u5217\u3002\u8fd9\u6837\u5728git show-branch &#8211;more=4\u4e2d\u80fd\u770b\u5230\u3002<\/p>\n<pre class=\"post-pre\"><code>[master] Use American spellings\r\n[master^] use color instead of colour\r\n[master~2] Finish my colour haiku\r\n[master~3] Start my haiku\r\n<\/code><\/pre>\n<p>\u5728\u65c1\u8fb9\uff0c\u53ef\u4ee5\u9002\u5f53\u5730\u6539\u53d8\u987a\u5e8f\u3002<\/p>\n<p>\u4e0b\u4e00\u6b65\u8981\u505a\u7684\u662f\u5c06\u6d89\u53ca\u62fc\u5199\u7684\u4e24\u4e2a\u63d0\u4ea4\u5408\u5e76\u4e3a\u4e00\u4e2a\u63d0\u4ea4\u3002<\/p>\n<p>\u5c06\u6700\u8fd13\u4e2acommit\u4e0e\u4e3b\u5206\u652f\u8fdb\u884c\u4ea4\u4e92\u5f0f\u7684\u57fa\u7840\u91cd\u7ec4<\/p>\n<pre class=\"post-pre\"><code>pick ed2232c Finish my colour haiku\r\npick dcea66f use color instead of colour\r\nsquash 7279eaf Use American spellings\r\n<\/code><\/pre>\n<p>\u4fdd\u5b58\u540e\u8fdb\u5165\u4fee\u6539\u63d0\u4ea4\u4fe1\u606f\u3002<\/p>\n<pre class=\"post-pre\"><code># This is a combination of 2 commits.\r\n# This is the 1st commit message:\r\n\r\nuse color instead of colour\r\n\r\n# This is the commit message #2:\r\n\r\nUse American spellings\r\n\r\n# Please enter the commit message for your changes. Lines starting\r\n# with '#' will be ignored, and an empty message aborts the commit.\r\n#\r\n# Date:      Sun Nov 17 23:09:56 2019 +0900\r\n#\r\n# interactive rebase in progress; onto 505057b\r\n# Last commands done (3 commands done):\r\n#    pick dcea66f use color instead of colour\r\n#    squash 7279eaf Use American spellings\r\n# No commands remaining.\r\n# You are currently rebasing branch 'master' on '505057b'.\r\n#\r\n# Changes to be committed:\r\n#   modified:   haiku\r\n#\r\n<\/code><\/pre>\n<p>\u4fee\u6539\u63d0\u4ea4\u4fe1\u606f\u3002<\/p>\n<p>git show-branch &#8211;more=4 \u7684\u672c\u5730\u5316\u4e2d\u6587\u89e3\u91ca\u5982\u4e0b\uff1a\u5c55\u793a\u5206\u652f\u72b6\u6001\uff0c\u4ee5\u66f4\u591a\u9009\u9879\u663e\u793a4\u4e2a\u5206\u652f\u3002<\/p>\n<pre class=\"post-pre\"><code>[master] Use American spellings\r\n[master^] Finish my colour haiku\r\n[master~2] Start my haiku\r\n<\/code><\/pre>\n<p>\u901a\u8fc7\u8fd9\u4e2a\u6b65\u9aa4\uff0c\u6211\u4eec\u5f97\u5230\u4e86\u6240\u9700\u7684\u63d0\u4ea4\u5386\u53f2\u8bb0\u5f55\u3002\u8fd9\u6b21\u6211\u4eec\u8c03\u7528\u4e86\u4e24\u6b21git rebase -i master~3\uff0c\u4f46\u4e5f\u53ef\u4ee5\u4e00\u6b21\u6027\u8fdb\u884c\u3002<\/p>\n<h2>\u8fdc\u7a0b\u5b58\u50a8\u5e93<\/h2>\n<p>\u4ee5\u524d\u53ea\u5904\u7406\u4e00\u4e2a\u672c\u5730\u4ed3\u5e93\uff0c\u4f46\u4ece\u73b0\u5728\u5f00\u59cb\u4e5f\u8981\u8003\u8651\u5206\u5e03\u5f0f\u529f\u80fd\u3002<\/p>\n<p>\u514b\u9686\u662f\u6307\u590d\u5236\u5b58\u50a8\u5e93\u3002\u514b\u9686\u5305\u542b\u4e86\u539f\u59cb\u5b58\u50a8\u5e93\u7684\u6240\u6709\u5bf9\u8c61\uff0c\u56e0\u6b64\u662f\u4e00\u4e2a\u72ec\u7acb\u7684\u81ea\u4e3b\u5b58\u50a8\u5e93\uff0c\u5e76\u4e0e\u539f\u59cb\u5b58\u50a8\u5e93\u771f\u6b63\u5730\u76f8\u5173\u8054\u3002\u514b\u9686\u5b58\u50a8\u5e93\u53ea\u662f\u4ee3\u7801\u5171\u4eab\u7684\u7b2c\u4e00\u6b65\u3002\u4e3a\u4e86\u5efa\u7acb\u6570\u636e\u4ea4\u6362\u8def\u5f84\uff0c\u9700\u8981\u5c06\u4e00\u4e2a\u5b58\u50a8\u5e93\u4e0e\u53e6\u4e00\u4e2a\u5b58\u50a8\u5e93\u76f8\u5173\u8054\u3002Git\u901a\u8fc7\u201c\u8fdc\u7a0b\u201d\u5b9e\u73b0\u8fd9\u79cd\u5b58\u50a8\u5e93\u7684\u8fde\u63a5\u3002<\/p>\n<p>\u8fdc\u7a0b\u662f\u6307\u53c2\u8003\u53e6\u4e00\u4e2a\u4ed3\u5e93\u6216\u4f7f\u7528\u7684\u522b\u540d\u3002\u4f5c\u4e3a\u957f\u800c\u590d\u6742\u7684Git URL\u7684\u7f29\u77ed\u540d\u79f0\uff0c\u8fdc\u7a0b\u7528\u4e8e\u7f29\u5199\u3002\u5728\u4e00\u4e2a\u4ed3\u5e93\u4e2d\u53ef\u4ee5\u5b9a\u4e49\u591a\u4e2a\u8fdc\u7a0b\u3002\u56e0\u6b64\uff0c\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u76f8\u4e92\u5171\u4eab\u7684\u590d\u6742\u7f51\u7edc\u3002\u4e00\u65e6\u5efa\u7acb\u4e86\u8fdc\u7a0b\u8fde\u63a5\uff0cGit\u53ef\u4ee5\u4f7f\u7528\u63a8\u9001\u6a21\u578b\u6216\u62c9\u53d6\u6a21\u578b\u5c06\u6570\u636e\u4ece\u4e00\u4e2a\u4ed3\u5e93\u4f20\u8f93\u5230\u53e6\u4e00\u4e2a\u4ed3\u5e93\u3002\u4f8b\u5982\uff0c\u4e3a\u4e86\u4fdd\u6301\u514b\u9686\u7684\u540c\u6b65\u3002\u53ef\u4ee5\u521b\u5efa\u8fdc\u7a0b\u6765\u5c06\u514b\u9686\u4e2d\u7684\u6570\u636e\u4f20\u8f93\u5230\u539f\u59cb\u4ed3\u5e93\uff0c\u4e5f\u53ef\u4ee5\u8bbe\u7f6e\u53cc\u5411\u4f20\u8f93\u4fe1\u606f\u4ee5\u4fbf\u4ea4\u6362\u4e24\u4e2a\u4ed3\u5e93\u4e4b\u95f4\u7684\u4fe1\u606f\u3002<\/p>\n<p>\u4e3a\u4e86\u8ffd\u8e2a\u6765\u81ea\u5176\u4ed6\u5b58\u50a8\u5e93\u7684\u6570\u636e\uff0cGit \u4f7f\u7528\u8ffd\u8e2a\u5206\u652f\u3002\u5b58\u50a8\u5e93\u4e2d\u7684\u8ffd\u8e2a\u5206\u652f\u662f\u672c\u5730\u5206\u652f\uff0c\u5b83\u4eec\u5206\u522b\u5145\u5f53\u8fde\u63a5\u5230\u7279\u5b9a\u8fdc\u7a0b\u5206\u652f\u7684\u4ee3\u7406\u3002<\/p>\n<p>\u5728Git\u4e2d\uff0c\u60a8\u53ef\u4ee5\u5c06\u5b58\u50a8\u5e93\u63d0\u4f9b\u7ed9\u5176\u4ed6\u7528\u6237\uff0c\u901a\u5e38\u79f0\u4e3a\u5b58\u50a8\u5e93\u516c\u5f00\u3002\u6709\u51e0\u79cd\u65b9\u6cd5\u53ef\u4ee5\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002<\/p>\n<h3>\u4ee3\u7801\u5e93\u6982\u5ff5\uff08\u88f8\u5e93\u548c\u5f00\u53d1\u5e93\uff09<\/h3>\n<p>Git\u7684\u4ee3\u7801\u5e93\u53ef\u4ee5\u662f\u88f8\u5e93\uff08bare repository\uff09\u6216\u975e\u88f8\u5e93\uff08non-bare repository\uff09\u4e2d\u7684\u4e00\u4e2a\u3002<br \/>\n\u975e\u88f8\u5e93\u901a\u5e38\u7528\u4e8e\u5e38\u89c4\u5f00\u53d1\uff0c\u5b83\u662f\u666e\u901a\u5206\u652f\uff08normal branch\uff09\u3002\u975e\u88f8\u5e93\u5177\u6709\u5f53\u524d\u5206\u652f\u7684\u6982\u5ff5\uff0c\u5e76\u63d0\u4f9b\u4e86\u5728\u5de5\u4f5c\u76ee\u5f55\u4e2d\u5f53\u524d\u5206\u652f\u7684\u68c0\u51fa\u526f\u672c\u3002\u524d\u9762\u63d0\u5230\u7684\u5e93\u57fa\u672c\u4e0a\u90fd\u662f\u5f00\u53d1\u5206\u652f\u3002<br \/>\n\u88f8\u5e93\u6ca1\u6709\u5de5\u4f5c\u76ee\u5f55\uff0c\u901a\u5e38\u4e0d\u7528\u4e8e\u5e38\u89c4\u5f00\u53d1\u3002\u88f8\u5e93\u6ca1\u6709\u68c0\u51fa\u5206\u652f\u7684\u6982\u5ff5\uff0c\u4e0d\u5e94\u76f4\u63a5\u5728\u88f8\u5e93\u4e0a\u6267\u884c\u63d0\u4ea4\u64cd\u4f5c\u3002\u88f8\u5e93\u626e\u6f14\u7740\u5171\u540c\u5f00\u53d1\u4e2d\u53ef\u9760\u57fa\u7840\u7684\u91cd\u8981\u89d2\u8272\u3002\u5f00\u53d1\u8005\u53ef\u4ee5\u4ece\u88f8\u5e93\u4e2d\u514b\u9686\u6216\u62c9\u53d6\u66f4\u65b0\uff0c\u5e76\u63a8\u9001\u66f4\u65b0\u3002\u5982\u679c\u8981\u5efa\u7acb\u4e00\u4e2a\u4f9b\u591a\u4e2a\u5f00\u53d1\u8005\u63a8\u9001\u66f4\u6539\u7684\u4ee3\u7801\u5e93\uff0c\u5e94\u8be5\u9009\u62e9\u8bbe\u7f6e\u4e3a\u88f8\u5e93\u3002<\/p>\n<p>\u5982\u679c\u5728git clone\u547d\u4ee4\u540e\u52a0\u4e0a&#8211;bare\u9009\u9879\uff0c\u5c31\u4f1a\u521b\u5efa\u4e00\u4e2a\u88f8\u5b58\u50a8\u5e93\uff1b\u5426\u5219\u5c31\u4f1a\u521b\u5efa\u4e00\u4e2a\u5f00\u53d1\u5b58\u50a8\u5e93\u3002<\/p>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cGit\u5728\u5f00\u53d1\u4ed3\u5e93\u4e2d\u542f\u7528reflog\uff08\u5f15\u7528\u66f4\u6539\u8bb0\u5f55\uff09\uff0c\u4f46\u5728\u88f8\u4ed3\u5e93\u4e2d\u4e0d\u542f\u7528\u3002\u4ece\u8fd9\u4e00\u4e8b\u5b9e\u53ef\u4ee5\u786e\u8ba4\u5728\u88f8\u4ed3\u5e93\u4e2d\u4e0d\u8fdb\u884c\u5f00\u53d1\u5de5\u4f5c\u3002<\/p>\n<h3>\u514b\u9686\u5b58\u50a8\u5e93<\/h3>\n<p>\u4f7f\u7528git clone\u547d\u4ee4\u53ef\u4ee5\u57fa\u4e8e\u6307\u5b9a\u7684\u6e90\u4ee3\u7801\u4ed3\u5e93\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Git\u4ed3\u5e93\u3002\u7136\u800c\uff0c\u5b83\u5e76\u4e0d\u4f1a\u590d\u5236\u6e90\u4ee3\u7801\u4ed3\u5e93\u7684\u6240\u6709\u4fe1\u606f\uff0c\u800c\u662f\u5ffd\u7565\u4ec5\u5728\u6e90\u4ee3\u7801\u4ed3\u5e93\u4e2d\u5177\u6709\u6301\u4e45\u6027\u7684\u4fe1\u606f\u3002\u4f8b\u5982\uff0c\u6e90\u4ee3\u7801\u4ed3\u5e93\u4e2d\u7684refs\/remotes\/\u76ee\u5f55\u4e2d\u7684\u8ffd\u8e2a\u5206\u652f\u4e0d\u4f1a\u88ab\u590d\u5236\u3002\u540c\u65f6\uff0c\u914d\u7f6e\u6587\u4ef6\u3001reflog\u4ee5\u53ca\u6e90\u4ee3\u7801\u4ed3\u5e93\u7684\u9690\u85cf\u4fe1\u606f\u4e5f\u4e0d\u4f1a\u88ab\u590d\u5236\u3002\u901a\u8fc7git clone\u547d\u4ee4\uff0c\u6e90\u4ee3\u7801\u4ed3\u5e93\u4e2d\u5b58\u50a8\u5728refs\/heads\/\u76ee\u5f55\u4e2d\u7684\u672c\u5730\u5f00\u53d1\u5206\u652f\u4f1a\u6210\u4e3a\u65b0\u514b\u9686\u4ed3\u5e93\u4e2drefs\/remotes\/\u76ee\u5f55\u4e0b\u7684\u8fdc\u7a0b\u8ffd\u8e2a\u5206\u652f\u3002\u6b64\u5916\uff0c\u6e90\u4ee3\u7801\u4ed3\u5e93\u4e2d\u7684\u6807\u7b7e\u4e5f\u4f1a\u88ab\u590d\u5236\u5230\u514b\u9686\u4ed3\u5e93\u4e2d\u3002<\/p>\n<p>\u4f7f\u7528\u547d\u4ee4&#8221;git clone https:\/\/github.com\/pytorch\/examples.git&#8221;\u5c06\u8be5\u9879\u76ee\u4eceGitHub\u514b\u9686\u5230\u672c\u5730\u3002<\/p>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u65b0\u7684\u514b\u9686\u901a\u8fc7\u79f0\u4e3aorigin\u7684\u8fdc\u7a0b\u4fdd\u6301\u5bf9\u7236\u5b58\u50a8\u5e93\u7684\u94fe\u63a5\u3002\u53ef\u4ee5\u5728\u514b\u9686\u4e86Github\u7b49\u5b58\u50a8\u5e93\u540e\u67e5\u770b.git\/config\u6587\u4ef6\u6765\u4e86\u89e3\u8be6\u60c5\u3002\u8bf7\u6ce8\u610f\uff0c\u539f\u5b58\u50a8\u5e93\u65e2\u4e0d\u5305\u542b\u4efb\u4f55\u6709\u5173\u4efb\u4f55\u514b\u9686\u7684\u4fe1\u606f\uff0c\u4e5f\u4e0d\u4fdd\u6301\u5bf9\u514b\u9686\u7684\u94fe\u63a5\u3002\u6b64\u5916\uff0corigin\u8fd9\u4e2a\u540d\u79f0\u6ca1\u6709\u7279\u6b8a\u542b\u4e49\u3002\u5982\u679c\u9700\u8981\u66f4\u6539\u6b64\u540d\u79f0\uff0c\u53ef\u4ee5\u5728\u514b\u9686\u65f6\u4f7f\u7528&#8211;origin name\u9009\u9879\u6765\u66f4\u6539\u4e3aname\u3002<\/p>\n<p>Git\u901a\u8fc7\u4f7f\u7528\u9ed8\u8ba4\u7684fetch refspec\u6765\u8bbe\u7f6e\u9ed8\u8ba4\u7684origin\u8fdc\u7a0b\u914d\u7f6e\u3002<\/p>\n<pre class=\"post-pre\"><code># .git\/config\u3092\u898b\u308b\r\nfetch = +refs\/heads\/*:refs\/remotes\/origin\/*\r\n<\/code><\/pre>\n<p>\u901a\u8fc7\u5efa\u7acb\u6b64refspec\uff0c\u8868\u660e\u4e86\u5e0c\u671b\u901a\u8fc7\u4ece\u539f\u59cb\u5b58\u50a8\u5e93\u83b7\u53d6\u66f4\u6539\u6765\u7ee7\u7eed\u66f4\u65b0\u672c\u5730\u5b58\u50a8\u5e93\u7684\u610f\u56fe\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u8fdc\u7a0b\u5b58\u50a8\u5e93\u7684\u5206\u652f\u53ef\u4ee5\u5728\u514b\u9686\u4e2d\u4f7f\u7528\u4ee5origin\/\u5f00\u5934\u7684\u5206\u652f\u540d\u79f0\uff0c\u5982origin\/master\u6216origin\/dev\u3002<\/p>\n<h3>\u8fdc\u7a0b<\/h3>\n<p>\u5f53\u524d\u6b63\u5728\u4f7f\u7528\u7684\u5b58\u50a8\u5e93\u88ab\u79f0\u4e3a\u672c\u5730\u5b58\u50a8\u5e93\uff08\u5f53\u524d\u5b58\u50a8\u5e93\uff09\uff0c\u7528\u4e8e\u4ea4\u6362\u6587\u4ef6\u7684\u5bf9\u65b9\u5b58\u50a8\u5e93\u79f0\u4e3a\u8fdc\u7a0b\u5b58\u50a8\u5e93\u3002<\/p>\n<p>Git\u4f7f\u7528\u8fdc\u7a0b\u548c\u8ddf\u8e2a\u5206\u652f\u6765\u5f15\u7528\u548c\u534f\u52a9\u8fde\u63a5\u5230\u5176\u4ed6\u4ed3\u5e93\u3002\u8fdc\u7a0b\u63d0\u4f9b\u4e86\u4e00\u4e2a\u66f4\u53cb\u597d\u7684\u540d\u79f0\u6765\u4ee3\u66ff\u5b9e\u9645\u7684\u4ed3\u5e93URL\uff0c\u5e76\u4e14\u5728\u8ffd\u8e2a\u5206\u652f\u7684\u540d\u79f0\u4e2d\u53ef\u4ee5\u5c06\u5176\u4f5c\u4e3a\u4e00\u90e8\u5206\u3002<\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528git remote\u547d\u4ee4\u6765\u521b\u5efa\u3001\u5220\u9664\u3001\u64cd\u4f5c\u548c\u67e5\u770b\u8fdc\u7a0b\u4ed3\u5e93\u3002\u521b\u5efa\u7684\u8fdc\u7a0b\u4ed3\u5e93\u5c06\u88ab\u8bb0\u5f55\u5728.git\/config\u6587\u4ef6\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528git config\u547d\u4ee4\u8fdb\u884c\u64cd\u4f5c\u3002<\/p>\n<p>\u9664\u4e86\u4f7f\u7528git clone\u547d\u4ee4\u5916\uff0c\u5176\u4ed6\u5e38\u7528\u7684\u6307\u4ee4\u7528\u4e8e\u5f15\u7528\u8fdc\u7a0b\u4ed3\u5e93\u5982\u4e0b\uff1a<br \/>\n&#8211; git fetch \u4ece\u8fdc\u7a0b\u4ed3\u5e93\u83b7\u53d6\u5bf9\u8c61\u548c\u76f8\u5173\u5143\u6570\u636e<br \/>\n&#8211; git pull \u7c7b\u4f3c\u4e8egit fetch\uff0c\u4f46\u8fd8\u4f1a\u5c06\u53d8\u66f4\u5408\u5e76\u5230\u76f8\u5e94\u5206\u652f<br \/>\n&#8211; git push \u5c06\u5bf9\u8c61\u548c\u76f8\u5173\u5143\u6570\u636e\u4f20\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93<br \/>\n&#8211; git ls-remote \u663e\u793a\u8fdc\u7a0b\u5f15\u7528\u4e2d\u7684\u5185\u5bb9<\/p>\n<h3>\u8ffd\u8e2a\u5206\u652f<\/h3>\n<p>\u4e00\u65e6\u514b\u9686\u5b58\u50a8\u5e93\uff0c\u65e0\u8bba\u662f\u5728\u672c\u5730\u63d0\u4ea4\u8fd8\u662f\u521b\u5efa\u672c\u5730\u5206\u652f\uff0c\u90fd\u53ef\u4ee5\u8ddf\u968f\u539f\u59cb\u6e90\u5b58\u50a8\u5e93\u7684\u66f4\u6539\u3002\u6b64\u5916\uff0c\u5373\u4f7f\u6b63\u5728\u4e0a\u6e38\u5b58\u50a8\u5e93\uff08\u4e0a\u6e38\u5b58\u50a8\u5e93\uff09\u4e0a\u5de5\u4f5c\u7684\u5f00\u53d1\u4eba\u5458\u5df2\u7ecf\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3atest\u7684\u5206\u652f\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528test\u540d\u79f0\u521b\u5efa\u672c\u5730\u5206\u652f\u3002\u5728Git\u4e2d\uff0c\u901a\u8fc7\u8ddf\u8e2a\u5206\u652f\uff0c\u53ef\u4ee5\u8ddf\u968f\u4e24\u4e2atest\u5206\u652f\u3002<\/p>\n<p>\u5728\u514b\u9686\u5904\u7406\u4e2d\uff0cGit\u4f1a\u4e3a\u539f\u59cb\u5b58\u50a8\u5e93\u4e2d\u7684\u6bcf\u4e2a\u4e3b\u9898\u5206\u652f\u521b\u5efa\u8fdc\u7a0b\u8ddf\u8e2a\u5206\u652f\uff0c\u4ee5\u4fbf\u5728\u514b\u9686\u4e2d\u521b\u5efa\u3002\u672c\u5730\u5b58\u50a8\u5e93\u4f7f\u7528\u8ffd\u8e2a\u5206\u652f\u6765\u521b\u5efa\u514b\u9686\u7684\u8fdc\u7a0b\u8ddf\u8e2a\u5206\u652f\uff0c\u4ee5\u8ddf\u8e2a\u5b58\u50a8\u5728\u8fdc\u7a0b\u5b58\u50a8\u5e93\u4e2d\u7684\u6bcf\u4e2a\u4e3b\u9898\u5206\u652f\u3002\u672c\u5730\u5b58\u50a8\u5e93\u4f7f\u7528\u8ffd\u8e2a\u5206\u652f\u6765\u8ddf\u8e2a\u5bf9\u8fdc\u7a0b\u5b58\u50a8\u5e93\u8fdb\u884c\u7684\u66f4\u6539\u3002\u7531\u4e8e\u8ffd\u8e2a\u5206\u652f\u88ab\u7ec4\u7ec7\u5728\u5176\u72ec\u7279\u7684\u547d\u540d\u7a7a\u95f4\u4e2d\uff0c\u56e0\u6b64\u5728\u5b58\u50a8\u5e93\u5185\u521b\u5efa\u7684\u5206\u652f\uff08\u5373\u4e3b\u9898\u5206\u652f\uff09\u548c\u5b9e\u9645\u4e0a\u57fa\u4e8e\u4e0d\u540c\u8fdc\u7a0b\u5b58\u50a8\u5e93\u7684\u5206\u652f\uff08\u8ffd\u8e2a\u5206\u652f\uff09\u4e4b\u95f4\u6709\u660e\u786e\u7684\u533a\u522b\uff08\u8fdc\u7a0b\u5206\u652f\u5b58\u50a8\u5728refs\/remotes\/\u547d\u540d\u7a7a\u95f4\u4e2d\uff0c\u56e0\u6b64\u8fdc\u7a0b\u8ddf\u8e2a\u5206\u652forigin\/master\u5b9e\u9645\u4e0a\u662frefs\/remotes\/origin\/master\uff09\u3002<\/p>\n<p>\u53ef\u4ee5\u5728\u5e38\u89c4\u7684\u4e3b\u9898\u5206\u652f\u4e0a\u6267\u884c\u7684\u6240\u6709\u64cd\u4f5c\u4e5f\u53ef\u4ee5\u5728\u8ffd\u8e2a\u5206\u652f\u4e0a\u6267\u884c\uff0c\u4f46\u662f\u6709\u4e00\u4e9b\u9650\u5236\u548c\u6307\u5bfc\u65b9\u9488\u3002\u8ffd\u8e2a\u5206\u652f\u7528\u4e8e\u8ddf\u8e2a\u6765\u81ea\u5176\u4ed6\u4ed3\u5e93\u7684\u66f4\u6539\uff0c\u56e0\u6b64\u4e0d\u5e94\u5bf9\u8ffd\u8e2a\u5206\u652f\u8fdb\u884c\u5408\u5e76\u6216\u63d0\u4ea4\u3002\u8fd9\u6837\u505a\u5c06\u5bfc\u81f4\u8ffd\u8e2a\u5206\u652f\u4e0d\u518d\u4e0e\u8fdc\u7a0b\u4ed3\u5e93\u540c\u6b65\u3002<\/p>\n<p>\u4e3a\u4e86\u534f\u540c\u5176\u5b83\u4ed3\u5e93\uff0c\u9700\u8981\u5f15\u7528\u5176\u5b83\u7684\u4ed3\u5e93\u3002\u4e3a\u4e86\u5b9e\u73b0\u8fd9\u4e00\u70b9\uff0c\u5b9a\u4e49\u4e00\u4e2a\u8fdc\u7a0b\u4ed3\u5e93\u3002\u8fdc\u7a0b\u4ed3\u5e93\u662f\u4e00\u4e2a\u5728\u4ed3\u5e93\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u5b58\u50a8\u7684\u5177\u540d\u5b9e\u4f53\u3002\u8fdc\u7a0b\u4ed3\u5e93\u7531\u4e24\u4e2a\u4e0d\u540c\u7684\u90e8\u5206\u7ec4\u6210\u3002\u4e00\u4e2a\u90e8\u5206\u4f7f\u7528URL\u683c\u5f0f\u6307\u5b9a\u53e6\u4e00\u4e2a\u4ed3\u5e93\u7684\u540d\u79f0\u3002\u7b2c\u4e8c\u90e8\u5206\u79f0\u4e3arefspec\uff0c\u5b83\u6307\u5b9a\u4e86\u5982\u4f55\u5c06\u5f15\u7528\u4ece\u4e00\u4e2a\u4ed3\u5e93\u7684\u547d\u540d\u7a7a\u95f4\u6620\u5c04\u5230\u53e6\u4e00\u4e2a\u4ed3\u5e93\u7684\u547d\u540d\u7a7a\u95f4\u7684\u65b9\u6cd5\u3002<\/p>\n<p>Git\u652f\u6301\u591a\u79cd\u683c\u5f0f\u7684URL\uff0c\u53ef\u4ee5\u6307\u5b9a\u8fdc\u7a0b\u5b58\u50a8\u5e93\u3002\u8fd9\u4e9b\u683c\u5f0f\u53ef\u4ee5\u6307\u5b9a\u8bbf\u95ee\u534f\u8bae\u3001\u6570\u636e\u4f4d\u7f6e\u6216\u4e24\u8005\u3002\u4e25\u683c\u6765\u8bf4\uff0cGit\u7684URL\u683c\u5f0f\u65e2\u4e0d\u662fURL\uff08\u7edf\u4e00\u8d44\u6e90\u5b9a\u4f4d\u7b26\uff09\u4e5f\u4e0d\u662fURI\uff08\u7edf\u4e00\u8d44\u6e90\u6807\u8bc6\u7b26\uff09\u3002\u7136\u800c\uff0c\u7531\u4e8eGit\u4f7f\u7528\u7684URL\u53d8\u79cd\u53ef\u4ee5\u591a\u7528\u9014\u5730\u6307\u5b9aGit\u5b58\u50a8\u5e93\u7684\u4f4d\u7f6e\uff0c\u901a\u5e38\u88ab\u79f0\u4e3aGit URL\uff0c\u5177\u6709\u5f88\u5927\u7684\u5b9e\u7528\u4ef7\u503c\u3002<\/p>\n<p>\u4e00\u79cd\u7b80\u4fbf\u7684Git URL\u662f\u7528\u4e8e\u5f15\u7528\u672c\u5730\u6587\u4ef6\u7cfb\u7edf\u4e0a\u7684\u4ee3\u7801\u5e93\u3002<\/p>\n<pre class=\"post-pre\"><code>file:\/\/\/path\/to\/repo.git\r\n<\/code><\/pre>\n<p>\u5728\u5176\u4ed6\u5f62\u5f0f\u7684Git URL\u4e2d\uff0c\u4f1a\u5f15\u7528\u8fdc\u7a0b\u7cfb\u7edf\u4e0a\u7684\u5b58\u50a8\u5e93\u3002\u6700\u9ad8\u6548\u7684\u6570\u636e\u4f20\u8f93\u5f62\u5f0f\u662fGit\u539f\u751f\u534f\u8bae\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f8b\u5b50\u3002<\/p>\n<pre class=\"post-pre\"><code>git:\/\/example.com\/path\/to\/repo.git\r\n<\/code><\/pre>\n<p>\u4e3a\u4e86\u5efa\u7acb\u5b89\u5168\u4e14\u7ecf\u8fc7\u8ba4\u8bc1\u7684\u8fde\u63a5\uff0c\u53ef\u4ee5\u901a\u8fc7SSH\u8fde\u63a5\u6765\u96a7\u9053\u5316Git\u672c\u5730\u534f\u8bae\u3002<\/p>\n<pre class=\"post-pre\"><code>ssh:\/\/user@example.com:port\/path\/to\/repo.git\r\n<\/code><\/pre>\n<p>Git\u652f\u6301\u7c7b\u4f3cscp\u547d\u4ee4\u7684\u8bed\u6cd5\u683c\u5f0f\u7684URL\u3002<\/p>\n<pre class=\"post-pre\"><code>user@example.com:\/path\/to\/repo.git\r\n<\/code><\/pre>\n<p>HTTP\u548cHTTPS\u7684URL\u683c\u5f0f\u4e5f\u5b8c\u5168\u88ab\u652f\u6301\uff0c\u4f46\u5e76\u4e0d\u50cf\u539f\u751f\u7684Git\u534f\u8bae\u90a3\u6837\u9ad8\u6548\u3002<\/p>\n<pre class=\"post-pre\"><code>http:\/\/example.com\/path\/to\/repo.git\r\nhttps:\/\/example.com\/path\/to\/repo.git\r\n<\/code><\/pre>\n<h3>\u5f15\u7528\u89c4\u8303 gu\u012b<\/h3>\n<p>\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u53c2\u7167\u5c31\u662f\u5206\u652f\u7684\u540d\u79f0\u3002refspec\u7528\u4e8e\u5c06\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u7684\u5206\u652f\u540d\u79f0\u5bf9\u5e94\u5230\u672c\u5730\u4ed3\u5e93\u4e2d\u7684\u5206\u652f\u540d\u79f0\u3002refspec\u9700\u8981\u540c\u65f6\u6307\u5b9a\u672c\u5730\u4ed3\u5e93\u548c\u8fdc\u7a0b\u4ed3\u5e93\u7684\u5206\u652f\u3002\u56e0\u6b64\uff0c\u5728refspec\u4e2d\u901a\u5e38\u4f7f\u7528\u5b8c\u6574\u7684\u5206\u652f\u540d\u79f0\uff0c\u5e76\u4e14\u7ecf\u5e38\u662f\u5fc5\u9700\u7684\u3002\u5728refspec\u4e2d\uff0c\u5f00\u53d1\u5206\u652f\u540d\u79f0\u901a\u5e38\u5177\u6709ref\/heads\/\u524d\u7f00\uff0c\u800c\u8ffd\u8e2a\u5206\u652f\u540d\u79f0\u901a\u5e38\u5177\u6709refs\/remotes\/\u524d\u7f00\u3002refspec\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre class=\"post-pre\"><code>[+]source:destination\r\n<\/code><\/pre>\n<p>refspec\u901a\u5e38\u7531\u6e90\u5f15\u7528\uff08source ref\uff09\u3001\u5192\u53f7\u548c\u76ee\u7684\u5730\u5f15\u7528\uff08destination ref\uff09\u7ec4\u6210\u3002\u5982\u679c\u6dfb\u52a0\u4e86\u52a0\u53f7\u7b26\u53f7\uff0c\u5219\u5728\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u5c06\u4e0d\u518d\u6267\u884c\u57fa\u4e8e\u5feb\u8fdb\u7684\u5b89\u5168\u6027\u68c0\u67e5\u3002\u6b64\u5916\uff0c\u53ef\u4ee5\u4f7f\u7528\u661f\u53f7\u5728\u53d7\u9650\u683c\u5f0f\u7684\u5206\u652f\u540d\u79f0\u4e0a\u5339\u914d\u901a\u914d\u7b26\u3002<\/p>\n<p>refspec\u7684\u683c\u5f0f\u5e38\u4e3a&#8221;source:destination&#8221;\uff0c\u4f46\u662f\u6839\u636eGit\u7684\u64cd\u4f5c\uff0c&#8221;source&#8221;\u548c&#8221;destination&#8221;\u7684\u4f5c\u7528\u662f\u4e0d\u540c\u7684\u3002<\/p>\n<p>\u5982\u679c\u4ee5git push\u4e3a\u4f8b\uff0csource\u5c31\u662f\u672c\u5730\u63a8\u9001\u7684\u5f15\u7528\uff0c\u800cdestination\u5c31\u662f\u66f4\u65b0\u7684\u8fdc\u7a0b\u5f15\u7528\uff1b\u800c\u5982\u679c\u4ee5git fetch\u4e3a\u4f8b\uff0csource\u5c31\u662f\u8fdc\u7a0b\u6293\u53d6\u7684\u5f15\u7528\uff0c\u800cdestination\u5219\u662f\u66f4\u65b0\u7684\u672c\u5730\u5f15\u7528\u3002<\/p>\n<p>\u5728\u5178\u578b\u7684\u7684git fetch\u547d\u4ee4\u4e2d\uff0c\u4f7f\u7528\u5982\u4e0b\u7684refspec\u3002<\/p>\n<p>\u5c06\u4ee5\u4e0b\u5185\u5bb9\u7528\u6c49\u8bed\u8fdb\u884c\u672c\u5730\u5316\u63cf\u8ff0\uff0c\u53ea\u9700\u7ed9\u51fa\u4e00\u79cd\u9009\u9879\uff1a<br \/>\n+refs\/heads\/:refs\/remotes\/origin\/<\/p>\n<p>+refs\/heads\/ \u6307\u672c\u5730\u5206\u652f\uff0c<br \/>\n:refs\/remotes\/origin\/ \u6307\u8fdc\u7a0b\u5206\u652f\u3002<\/p>\n<p>\u8fd9\u4e2arefspec\u53ef\u4ee5\u8fd9\u6837\u7528\u4e2d\u6587\u8868\u8fbe\uff1a<br \/>\n\u6240\u6709\u5728\u8fdc\u7a0b\u5b58\u50a8\u5e93\u7684\u540d\u79f0\u7a7a\u95f4refs\/heads\/\u4e2d\u7684\u6e90\u4ee3\u7801\u5206\u652f\u5c06\u4f7f\u7528\u4ee5origin\u547d\u540d\u4e3a\u57fa\u7840\u7684\u540d\u79f0\u4e0e\u672c\u5730\u5b58\u50a8\u5e93\u76f8\u5bf9\u5e94\uff0c\u5e76\u4f4d\u4e8erefs\/remotes\/origin\u540d\u79f0\u7a7a\u95f4\u4e0b\u3002<\/p>\n<p>\u7531\u4e8e\u6b64refspec\u5305\u542b\u661f\u53f7\uff0c\u56e0\u6b64\u5c06\u5e94\u7528\u4e8e\u5728\u8fdc\u7a0b\u7684refs\/heads\/*\u4e0b\u627e\u5230\u7684\u591a\u4e2a\u5206\u652f\u3002<\/p>\n<p>refspec\u662f\u5728git fetch\uff08git pull\uff09\u548cgit push\u4e2d\u4f7f\u7528\u7684\u3002\u53ef\u4ee5\u5728git fetch\u548cgit push\u547d\u4ee4\u884c\u4e2d\u4f20\u9012\u591a\u4e2arefspec\u3002<\/p>\n<p>\u4e3a\u4e86\u7b80\u5355\u8d77\u89c1\uff0c\u6211\u4eec\u51b3\u5b9a\u5728\u4e00\u53f0\u8ba1\u7b97\u673a\u4e0a\u8fd0\u884c\u591a\u4e2a\u4ed3\u5e93\u3002\u5373\u4f7f\u4f7f\u7528\u5176\u4ed6\u683c\u5f0f\u7684\u8fdc\u7a0bURL\u8868\u793a\u6cd5\uff0c\u4e5f\u53ef\u4ee5\u5728\u7269\u7406\u4e0a\u4e0d\u540c\u7684\u673a\u5668\u4e0a\u5e94\u7528\u76f8\u540c\u7684\u673a\u5236\u3002<\/p>\n<p>\u5047\u8bbe\u6240\u6709\u7684\u5f00\u53d1\u8005\u90fd\u60f3\u8981\u5efa\u7acb\u4e00\u4e2a\u88ab\u8ba4\u4e3a\u6709\u6743\u5a01\u7684\u4ee3\u7801\u5e93\u3002\u8fd9\u4e2a\u7ecf\u8fc7\u5171\u8bc6\u7684\u6743\u5a01\u526f\u672c\u901a\u5e38\u88ab\u653e\u7f6e\u5728\u4e00\u4e2a\u7279\u6b8a\u7684\u76ee\u5f55\u4e2d\uff0c\u88ab\u79f0\u4e3adepot\uff08\u4ed3\u5e93\uff09\u3002\u4e3a\u4e86\u5c55\u793a\u5728\u8fd9\u4e2a\u4ee3\u7801\u5e93\u4e2d\u7684\u5e76\u884c\u5f00\u53d1\u60c5\u51b5\uff0c\u7b2c\u4e8c\u4e2a\u5f00\u53d1\u8005\u5c06\u8fdb\u884c\u514b\u9686\uff0c\u5e76\u5728\u672c\u5730\u4ee3\u7801\u5e93\u4e0a\u8fdb\u884c\u5de5\u4f5c\uff0c\u7136\u540e\u5c06\u66f4\u6539\u63a8\u9001\u5230depot\uff0c\u4ee5\u4f9b\u6240\u6709\u4eba\u4f7f\u7528\u3002<\/p>\n<p>\u6211\u5011\u6c7a\u5b9a\u5c07\u6240\u559c\u6b61\u7684\u76ee\u9304\uff08\u4f8b\u5982\/tmp\/Depot\uff09\u8b8a\u6210\u4e00\u500b\u53d7\u6b0a\u5a01\u7684\u5b58\u5132\u5eab\u3002\u4e0d\u61c9\u5728\/tmp\/Depot\u76ee\u9304\u53ca\u5176\u5167\u90e8\u7684\u5b58\u5132\u5eab\u4e2d\u9032\u884c\u5be6\u969b\u7684\u958b\u767c\u5de5\u4f5c\u3002\u61c9\u8a72\u5728\u672c\u5730\u514b\u9686\u4e2d\u9032\u884c\u500b\u5225\u5de5\u4f5c\u3002<\/p>\n<p>\u6700\u5f00\u59cb\u521b\u5efa\/tmp\/Depot\uff0c\u5e76\u51c6\u5907\u521d\u59cb\u4ed3\u5e93\u3002\u5047\u8bbe~\/public_html\u5df2\u7ecf\u4f5c\u4e3aGit\u4ed3\u5e93\u51c6\u5907\u597d\uff08\u5047\u8bbe\u8be5\u4ed3\u5e93\u662f\u901a\u8fc7git init\u521b\u5efa\u7684\uff09\uff0c\u73b0\u5728\u8981\u5728\u5176\u4e2d\u7f16\u8f91\u7f51\u7ad9\u5185\u5bb9\u3002\u6b64\u65f6\u9700\u8981\u521b\u5efa~\/public_html\u4ed3\u5e93\u7684\u526f\u672c\uff0c\u5e76\u5c06\u5176\u653e\u7f6e\u5728\/tmp\/Depot\/public_html\u4e2d\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nb\">cd<\/span> \/tmp\/Depot\/\r\ngit clone <span class=\"nt\">--bare<\/span> ~\/public_html public_html.git\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>Cloning into bare repository 'public_html.git'...\r\ndone.\r\n<\/code><\/pre>\n<p>\u8fd9\u4e2a clone \u547d\u4ee4\u4f1a\u5c06 Git \u7684\u8fdc\u7a0b\u4ed3\u5e93\u4ece ~\/public_html \u590d\u5236\u5230\u5f53\u524d\u76ee\u5f55 \/tmp\/Depot\u3002\u6839\u636e\u60ef\u4f8b\uff0c\u88f8\u4ed3\u5e93\u5e94\u8be5\u4ee5 .git \u4f5c\u4e3a\u540e\u7f00\u6765\u547d\u540d\u3002\uff08\u5c3d\u7ba1 git clone &#8211;bare ~\/public_html \u5e76\u4e0d\u9644\u5e26 .git\uff0c\u4e5f\u4f1a\u521b\u5efa public_html.git\uff09<\/p>\n<pre class=\"post-pre\"><code>cd ~\/public_html\r\nls -a\r\n.          ..         .git       index.html test\r\n<\/code><\/pre>\n<p>\u7531\u4e8eBare Repository\u6ca1\u6709\u5de5\u4f5c\u76ee\u5f55\uff0c\u56e0\u6b64\u6587\u4ef6\u7ed3\u6784\u5c06\u66f4\u52a0\u7b80\u5355\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nb\">cd<\/span> \/tmp\/Depot\/public_html.git\r\n<span class=\"nb\">ls<\/span> <span class=\"nt\">-a<\/span>\r\n<span class=\"nb\">.<\/span>           ..          HEAD        branches    config      description hooks       info        objects     packed-refs refs\r\n<\/code><\/pre>\n<p>\u4ece\u73b0\u5728\u8d77\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u6b64\u5b58\u50a8\u5e93\/tmp\/Depot\/public_html.git\u4f5c\u4e3a\u6743\u5a01\u5b58\u50a8\u5e93\u6765\u5904\u7406\u3002<\/p>\n<pre class=\"post-pre\"><code>cat config\r\n[core]\r\n    repositoryformatversion = 0\r\n    filemode = true\r\n    bare = true\r\n    ignorecase = true\r\n    precomposeunicode = true\r\n<\/code><\/pre>\n<p>\u7528\u8fd9\u4e2a\u65b9\u6cd5\u6211\u4eec\u521b\u5efa\u4e86\u4e24\u4e2a\u4ed3\u5e93\uff0c\u4f46\u662f\u4e24\u4e2a\u4ed3\u5e93\u95f4\u6709\u4e2a\u4e0d\u540c\u4e4b\u5904\u662f\u539f\u4ed3\u5e93\u6709\u4e00\u4e2a\u5de5\u4f5c\u76ee\u5f55\uff0c\u800c\u88f8\u514b\u9686\u5219\u6ca1\u6709\u3002~\/public_html\u4ed3\u5e93\u662f\u901a\u8fc7git init\u547d\u4ee4\u521b\u5efa\u7684\uff0c\u6240\u4ee5\u4e0d\u5b58\u5728origin\u3002<\/p>\n<pre class=\"post-pre\"><code>cd ~\/pulic_html\r\ncat .git\/config\r\n[core]\r\n    repositoryformatversion = 0\r\n    filemode = true\r\n    bare = false\r\n    logallrefupdates = true\r\n    ignorecase = true\r\n    precomposeunicode = true\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>git remote add origin \/tmp\/Depot\/public_html\r\ncat .git\/config\r\n[core]\r\n    repositoryformatversion = 0\r\n    filemode = true\r\n    bare = false\r\n    logallrefupdates = true\r\n    ignorecase = true\r\n    precomposeunicode = true\r\n[remote \"origin\"]\r\n    url = \/tmp\/Depot\/public_html.git\/\r\n    fetch = +refs\/heads\/*:refs\/remotes\/origin\/*\r\n<\/code><\/pre>\n<p>\u901a\u8fc7\u8fd9\u6b21git remote\u64cd\u4f5c\uff0c\u6dfb\u52a0\u4e86\u4e00\u4e2a\u540d\u4e3aorigin\u7684\u65b0\u7684remote\u90e8\u5206\u5230\u914d\u7f6e\u6587\u4ef6\u4e2d\u3002remote\u7528\u4e8e\u5728\u5f53\u524d\u4ed3\u5e93\u548c\u8fdc\u7a0b\u4ed3\u5e93\u4e4b\u95f4\u5efa\u7acb\u94fe\u63a5\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u8fdc\u7a0b\u4ed3\u5e93\u4f4d\u4e8e\/tmp\/Depot\/public_html.git\uff0c\u5e76\u8bb0\u5f55\u5728url\u503c\u4e2d\u3002\u56e0\u6b64\uff0c\u53ef\u4ee5\u4f7f\u7528origin\u4f5c\u4e3a\u8fdc\u7a0b\u4ed3\u5e93\u7684\u7b80\u79f0\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u8fd8\u6dfb\u52a0\u4e86\u6309\u7167\u60ef\u4f8b\u8fdb\u884c\u5206\u652f\u540d\u79f0\u8f6c\u6362\u7684fetch refspec\u3002<\/p>\n<p>\u5b8c\u6210\u539f\u59cb\u8fdc\u7a0b\u51c6\u5907\u3002\u4e3a\u4e86\u8868\u793a\u8fdc\u7a0b\u5b58\u50a8\u5e93\u4e2d\u7684\u5206\u652f\uff0c\u5728\u539f\u59cb\u5b58\u50a8\u5e93\u4e2d\u521b\u5efa\u65b0\u7684\u8ffd\u8e2a\u5206\u652f\u3002\u9996\u5148\u786e\u8ba4\u4e3b\u5206\u652f\u9884\u8ba1\u53ea\u6709\u4e00\u4e2a\u5b58\u5728\u3002<\/p>\n<pre class=\"post-pre\"><code>git branch -a\r\n* master\r\n\r\ngit remote update\r\nFetching origin\r\nFrom \/tmp\/Depo\/public_html.git\r\n * [new branch]      master     -&gt; origin\/master\r\n\r\ngit branch -a\r\n* master\r\n  remotes\/origin\/master\r\n<\/code><\/pre>\n<p>Git\u4f1a\u5728\u4ed3\u5e93\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aorigin\/master\u7684\u65b0\u5206\u652f\u3002\u8fd9\u662f\u4e00\u4e2a\u8ffd\u8e2a\u5206\u652f\uff0c\u8ffd\u8e2a\u7740\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u7684origin\u5206\u652f\u3002\u5b83\u4e0d\u7528\u4e8e\u5f00\u53d1\uff0c\u800c\u662f\u7528\u6765\u4fdd\u7559\u5e76\u8ffd\u8e2a\u8fdc\u7a0borigin\u4ed3\u5e93\u7684master\u5206\u652f\u4e0a\u7684\u63d0\u4ea4\u3002<\/p>\n<p>git remote update\u547d\u4ee4\u4f1a\u68c0\u67e5\u6307\u5b9a\u7684\u6bcf\u4e2a\u8fdc\u7a0b\u4ed3\u5e93\u7684\u65b0\u63d0\u4ea4\uff0c\u5e76\u901a\u8fc7\u6267\u884cfetch\u64cd\u4f5c\u6765\u66f4\u65b0\u6240\u6709\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u7684\u53d8\u52a8\u3002<\/p>\n<p>\u5728\u8fd9\u91cc\uff0c\u5728\u4ed3\u5e93\u4e2d\u63a8\u8fdb\u5f00\u53d1\uff0c\u5e76\u6dfb\u52a0fuzzy.txt\u3002<\/p>\n<pre class=\"post-pre\"><code>cd ~\/public_html\r\ngit show-branch -a\r\n* [master] add text\r\n ! [origin\/master] add text\r\n--\r\n*+ [master] add text\r\n\r\ncat fuzzy.txt\r\nFuzzy Wuzzy was a bear\r\nFuzzy Wuzzy had no hair\r\nFuzzy Wuzzy wasn't very fuzzy,\r\nWas he?\r\n\r\ngit add fuzzy.txt\r\ngit commit -m\"Add a hairy poem\"\r\n[master 8cd52b8] Add a hairy poem\r\n 1 file changed, 4 insertions(+)\r\n create mode 100644 fuzzy.txt\r\n<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u65f6\u5019\u6709\u610f\u601d\u7684\u662f\uff0c\u8fd9\u4e2a\u4ed3\u5e93\u6709\u4e24\u4e2a\u5206\u652f\uff08master\u548corigin\/master\uff09\u3002master\u662f\u5305\u542b\u65b0\u63d0\u4ea4\u7684\u5206\u652f\uff0c\u800corigin\/master\u662f\u8ffd\u8e2a\u8fdc\u7a0b\u4ed3\u5e93\u7684\u5206\u652f\u3002<\/p>\n<p>\u63d0\u4ea4\u66f4\u6539\u3002<\/p>\n<pre class=\"post-pre\"><code>git push origin\r\nEnumerating objects: 4, done.\r\nCounting objects: 100% (4\/4), done.\r\nDelta compression using up to 4 threads\r\nCompressing objects: 100% (3\/3), done.\r\nWriting objects: 100% (3\/3), 366 bytes | 366.00 KiB\/s, done.\r\nTotal 3 (delta 0), reused 0 (delta 0)\r\nTo \/tmp\/Depot\/public_html.git\/\r\n   2fd0efb..8cd52b8  master -&gt; master\r\n<\/code><\/pre>\n<p>\u4e0a\u8ff0\u7684\u8f93\u51fa\u610f\u5473\u7740Git\u63a5\u6536\u4e86\u4e3b\u5206\u652f\u7684\u53d8\u66f4\uff0c\u5e76\u5c06\u5176\u6574\u5408\u540e\u53d1\u9001\u5230\u540d\u4e3aorigin\u7684\u8fdc\u7a0b\u4ed3\u5e93\u3002\u6b64\u65f6\uff0cGit\u4f1a\u6267\u884c\u53e6\u4e00\u4e2a\u64cd\u4f5c\uff0c\u5373\u5c06\u76f8\u540c\u7684\u53d8\u66f4\u6dfb\u52a0\u5230\u60a8\u7684\u4ed3\u5e93\u7684origin\/master\u5206\u652f\u4e0a\u3002\u6b64\u64cd\u4f5c\u4f1a\u4f7f\u7528fast-forward\u65b9\u5f0f\u66f4\u65b0\u8ddf\u8e2a\u5206\u652f\u3002\u8fd9\u6837\uff0c\u672c\u5730\u7684master\u5206\u652f\u548corigin\/master\u5206\u652f\u90fd\u5c06\u53cd\u6620\u76f8\u540c\u7684\u4ed3\u5e93\u63d0\u4ea4\u3002<\/p>\n<pre class=\"post-pre\"><code>git show-branch -a\r\n* [master] Add a hairy poem\r\n ! [origin\/master] Add a hairy poem\r\n--\r\n*+ [master] Add a hairy poem\r\n\r\ncd \/tmp\/Depot\/public_html.git\r\ngit show-branch\r\n[master] Add a hairy poem\r\n<\/code><\/pre>\n<p>\u5728\u8fd9\u91cc\u6dfb\u52a0\u65b0\u7684\u5f00\u53d1\u4eba\u5458Bob\u3002<\/p>\n<pre class=\"post-pre\"><code>cd \/tmp\/Bob\r\ngit clone \/tmp\/Depot\/public_html.git\r\nCloning into 'public_html'...\r\ndone.\r\nls\r\npublic_html\r\ncd public_html\r\nfuzzy.txt  index.html test\r\n\r\ngit branch\r\n* master\r\n\r\ngit log -1\r\ncommit 8cd52b8d5f2b1badc632547625165723d10f08a2 (HEAD -&gt; master, origin\/master, origin\/HEAD)\r\nAuthor: git taro &lt;hello@example.com&gt;\r\nDate:   Sun Dec 8 00:30:00 2019 +0900\r\n\r\n    Add a hairy poem\r\n<\/code><\/pre>\n<p>Bob\u53ef\u4ee5\u5728\u4ed6\u7684\u5b58\u50a8\u5e93\u4e2d\u67e5\u627eorigin\u8fdc\u7a0b\u7684\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n<pre class=\"post-pre\"><code>git remote show origin\r\n* remote origin\r\n  Fetch URL: \/tmp\/Depot\/public_html.git\r\n  Push  URL: \/tmp\/Depot\/public_html.git\r\n  HEAD branch: master\r\n  Remote branch:\r\n    master tracked\r\n  Local branch configured for 'git pull':\r\n    master merges with remote master\r\n  Local ref configured for 'git push':\r\n    master pushes to master (up to date)\r\n<\/code><\/pre>\n<p>\u67e5\u770b\u8bbe\u7f6e\u6587\u4ef6\uff0c\u53ef\u4ee5\u770b\u5230\u514b\u9686\u5305\u542b\u4e86origin\u8fdc\u7a0b\u3002<\/p>\n<pre class=\"post-pre\"><code>cat .git\/config\r\n[core]\r\n    repositoryformatversion = 0\r\n    filemode = true\r\n    bare = false\r\n    logallrefupdates = true\r\n    ignorecase = true\r\n    precomposeunicode = true\r\n[remote \"origin\"]\r\n    url = \/tmp\/Depot\/public_html.git\r\n    fetch = +refs\/heads\/*:refs\/remotes\/origin\/*\r\n[branch \"master\"]\r\n    remote = origin\r\n    merge = refs\/heads\/master\r\n\r\ngit branch -a\r\n* master\r\n  remotes\/origin\/HEAD -&gt; origin\/master\r\n  remotes\/origin\/master\r\n<\/code><\/pre>\n<p>Bob\u7684\u5b58\u50a8\u5e93\u4e2d\u9664\u4e86origin\u8fdc\u7a0b\u4e4b\u5916\uff0c\u8fd8\u6709\u4e00\u4e9b\u5206\u652f\u3002master\u5206\u652f\u662fBob\u7684\u4e3b\u8981\u5f00\u53d1\u5206\u652f\uff0c\u4e5f\u662f\u5e38\u89c4\u7684\u672c\u5730\u5206\u652f\u3002remotes\/origin\/master\u5206\u652f\u662f\u7528\u6765\u8ddf\u8e2aorigin\u5b58\u50a8\u5e93\u7684master\u5206\u652f\u4e0a\u7684\u63d0\u4ea4\u7684\u8ffd\u8e2a\u5206\u652f\u3002remotes\/origin\/HEAD\u5206\u652f\u901a\u8fc7\u7b26\u53f7\u540d\u6307\u793a\u54ea\u4e2a\u5206\u652f\u88ab\u8fdc\u7a0b\u4f5c\u4e3a\u6d3b\u52a8\u5206\u652f\u5904\u7406\uff08\u6d3b\u52a8\u5206\u652f\u51b3\u5b9a\u5de5\u4f5c\u76ee\u5f55\u4e2d\u68c0\u51fa\u7684\u6587\u4ef6\uff09\u3002<\/p>\n<p>Bob\u6539\u5199\u4e86fuzzy.txt\u6587\u4ef6\uff0c\u5e76\u63d0\u4ea4\u5e76\u63a8\u9001\u5230\u4e3b\u8981\u7684\u4ee3\u7801\u4ed3\u5e93\u3002<\/p>\n<pre class=\"post-pre\"><code>git diff\r\ndiff --git a\/fuzzy.txt b\/fuzzy.txt\r\nindex 0d601fa..608ab5b 100644\r\n--- a\/fuzzy.txt\r\n+++ b\/fuzzy.txt\r\n@@ -1,4 +1,4 @@\r\n Fuzzy Wuzzy was a bear\r\n Fuzzy Wuzzy had no hair\r\n Fuzzy Wuzzy wasn't very fuzzy,\r\n-Was he?\r\n+Wuzzy?\r\n\r\ngit commit fuzzy.txt\r\n[master 6a36716] Make the name pun complete!\r\n 1 file changed, 1 insertion(+), 1 deletion(-)\r\n\r\ngit push\r\nEnumerating objects: 5, done.\r\nCounting objects: 100% (5\/5), done.\r\nDelta compression using up to 4 threads\r\nCompressing objects: 100% (3\/3), done.\r\nWriting objects: 100% (3\/3), 346 bytes | 346.00 KiB\/s, done.\r\nTotal 3 (delta 1), reused 0 (delta 0)\r\nTo \/tmp\/Depot\/public_html.git\/\r\n   8cd52b8..6a36716  master -&gt; master\r\n<\/code><\/pre>\n<p>\u5e0c\u671b\u5c06Bob\u7684\u66f4\u6539\u5e94\u7528\u5230\u4ed3\u5e93\u4e2d\u5e76\u4f7f\u5176\u4fdd\u6301\u6700\u65b0\u72b6\u6001\u3002\u6b64\u76ee\u7684\u53ef\u901a\u8fc7\u57fa\u672c\u547d\u4ee4git pull\u5b9e\u73b0\u3002<\/p>\n<pre class=\"post-pre\"><code>cd ~\/public_html\r\ngit pull\r\nremote: Enumerating objects: 5, done.\r\nremote: Counting objects: 100% (5\/5), done.\r\nremote: Compressing objects: 100% (3\/3), done.\r\nremote: Total 3 (delta 1), reused 0 (delta 0)\r\nUnpacking objects: 100% (3\/3), done.\r\nFrom \/tmp\/Depot\/public_html\r\n   8cd52b8..6a36716  master     -&gt; origin\/master\r\nUpdating 8cd52b8..6a36716\r\nFast-forward\r\n fuzzy.txt | 2 +-\r\n 1 file changed, 1 insertion(+), 1 deletion(-)\r\n<\/code><\/pre>\n<p>\u5b8c\u6574\u683c\u5f0f\u7684git pull\u53ef\u4ee5\u6307\u5b9a\u4ed3\u5e93\u548c\u591a\u4e2arefspec\u3002\u5b83\u7684\u683c\u5f0f\u4e3agit pull options repository refspecs\u3002\u5982\u679c\u5728\u547d\u4ee4\u884c\u4e2d\u6ca1\u6709\u6307\u5b9arepository\uff0c\u9ed8\u8ba4\u4f1a\u4f7f\u7528origin\u3002\u5982\u679c\u547d\u4ee4\u884c\u4e2d\u4e5f\u6ca1\u6709\u6307\u5b9arefspec\uff0c\u5219\u4f1a\u4f7f\u7528\u8fdc\u7a0b\u7684fetch refspec\u3002\u800c\u5982\u679c\u6307\u5b9a\u4e86\u4ed3\u5e93\uff0c\u4f46\u6ca1\u6709\u6307\u5b9arefspec\uff0cGit\u4f1a\u83b7\u53d6\u8fdc\u7a0b\u7684HEAD\u5f15\u7528\u3002<\/p>\n<p>git pull\u7684\u64cd\u4f5c\u5206\u4e3a\u4e24\u4e2a\u9636\u6bb5\u3002<br \/>\n\u7b2c\u4e00\u4e2a\u9636\u6bb5\u662fgit fetch\u3002\u7b2c\u4e8c\u4e2a\u9636\u6bb5\u53ef\u4ee5\u662fgit merge\u6216\u8005git rebase\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4f1a\u6267\u884cgit merge\u3002\u56e0\u6b64git pull\u548cgit push\u4e0d\u662f\u76f8\u53cd\u7684\u5173\u7cfb\u3002\u800cgit push\u548cgit fetch\u662f\u76f8\u53cd\u7684\u5173\u7cfb\u3002\u6709\u65f6\u5019\u6211\u4eec\u60f3\u5c06git fetch\u548cgit merge\u4f5c\u4e3a\u4e24\u4e2a\u5355\u72ec\u7684\u64cd\u4f5c\u6765\u6267\u884c\u3002\u4f8b\u5982\uff0c\u5f53\u6211\u4eec\u60f3\u8981\u83b7\u53d6\u66f4\u65b0\u5e76\u67e5\u770b\u5185\u5bb9\uff0c\u4f46\u4e0d\u7acb\u5373\u8fdb\u884c\u5408\u5e76\u65f6\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u4e0d\u4f7f\u7528git pull\uff0c\u800c\u662f\u5148\u8fdb\u884cgit fetch\uff0c\u7136\u540e\u5728\u8ffd\u8e2a\u5206\u652f\u4e0a\u6267\u884cgit log\u6216git diff\u7b49\u64cd\u4f5c\uff0c\u51c6\u5907\u597d\u65f6\u518d\u6267\u884cgit merge\u5373\u53ef\u3002\u8ba9\u6211\u4eec\u7a0d\u5fae\u8be6\u7ec6\u5730\u770b\u4e00\u4e0b\u8fd9\u4e24\u4e2a\u9636\u6bb5\u3002<\/p>\n<p>\u5728Git\u4e2d\uff0c\u5728fetch\u9636\u6bb5\uff0c\u9996\u5148\u4f1a\u786e\u5b9a\u8fdc\u7a0b\u5e93\u3002\u5982\u679c\u6ca1\u6709\u5728\u547d\u4ee4\u884c\u7b49\u6307\u5b9a\uff0c\u901a\u5e38\u4f1a\u9ed8\u8ba4\u4f7f\u7528\u8fdc\u7a0b\u540d\u79f0origin\u3002\u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u4e2d[remote &#8220;origin&#8221;]\u7684\u90e8\u5206\u6765\u786e\u5b9a\u6e90\u5e93\u7684URL\u3002\u63a5\u4e0b\u6765\uff0c\u4e3a\u4e86\u786e\u5b9a\u8fdc\u7a0b\u5e93\u4e2d\u6709\u54ea\u4e9b\u65b0\u7684\u63d0\u4ea4\uff0c\u4ee5\u53ca\u4f60\u7684\u5e93\u4e2d\u7f3a\u5c11\u54ea\u4e9b\u63d0\u4ea4\uff0cGit\u4f1a\u5728\u6e90\u5e93\u548c\u672c\u5730\u5e93\u4e4b\u95f4\u8fdb\u884c\u534f\u8bae\u534f\u5546\u3002\u8fd9\u662f\u57fa\u4e8efetch refspec\uff0c\u4e5f\u5c31\u662f\u8981\u83b7\u53d6\u6240\u6709refs\/heads\/*\u7684\u5f15\u7528\u3002<\/p>\n<pre class=\"post-pre\"><code>cat .git\/config\r\n[remote \"origin\"]\r\n    url = \/tmp\/Depot\/public_html.git\/\r\n    fetch = +refs\/heads\/*:refs\/remotes\/origin\/*\r\n<\/code><\/pre>\n<p>\u6240\u6709\u4ee5&#8221;\u306a\u304aremote:&#8221;\u5f00\u5934\u7684\u884c\u8868\u793a\u534f\u5546\u3001\u538b\u7f29\u548c\u4f20\u8f93\u534f\u8bae\u3002<br \/>\n\u8fd9\u4e24\u884c\u8f93\u51fa\u8868\u793aGit\u4f1a\u53bb\u67e5\u770b\u8fdc\u7a0b\u4ed3\u5e93\/tmp\/Depot\/public_html.git\uff0c\u5e76\u83b7\u53d6\u8be5\u4f4d\u7f6e\u7684master\u5206\u652f\u7684\u5185\u5bb9\uff0c\u7136\u540e\u5c06\u5176\u4f20\u8f93\u5230\u60a8\u7684\u4ed3\u5e93\u5e76\u5b58\u50a8\u5728\u60a8\u7684origin\/master\u5206\u652f\u4e2d\u3002\u56e0\u6b64\uff0c\u5728\u8fdb\u884cgit fetch\u4e4b\u540e\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7git checkout origin\/master\u6765\u67e5\u770b\u5de5\u4f5c\u76ee\u5f55\u4e2d\u7684\u66f4\u6539\u5185\u5bb9\u3002<\/p>\n<p>\u5728merge\u6216rebase\u9636\u6bb5\uff0cGit\u4f7f\u7528\u4e00\u79cd\u7279\u6b8a\u7c7b\u578b\u7684\u5408\u5e76\uff0c\u79f0\u4e3afast-forward\uff0c\u5c06\u8ffd\u8e2a\u5206\u652forigin\/master\u7684\u5185\u5bb9\u5408\u5e76\u5230\u4e3b\u5206\u652fmaster\u4e0a\u3002Git\u4f7f\u7528\u914d\u7f6e\u6587\u4ef6\u6765\u8bc6\u522b\u8fd9\u4e9b\u5206\u652f\u3002<\/p>\n<pre class=\"post-pre\"><code>cat .git\/config\r\n[branch \"master\"]\r\n    remote = origin\r\n    merge = refs\/heads\/master\r\n<\/code><\/pre>\n<p>\u5982\u679c\u5f53\u524d\u68c0\u51fa\u7684\u5206\u652f\u662fmaster\uff0c\u5219\u5728\u62c9\u53d6\u66f4\u65b0\u65f6\u4f7f\u7528origin\u4f5c\u4e3a\u9ed8\u8ba4\u8fdc\u7a0b\u4ed3\u5e93\uff0c\u5e76\u4e14\u5728git pull\u5408\u5e76\u9636\u6bb5\u65f6\u4f7f\u7528\u8fdc\u7a0b\u7684refs\/heads\/master\u4f5c\u4e3a\u9ed8\u8ba4\u5408\u5e76\u5206\u652f\uff0c\u8fd9\u5c31\u662f\u6240\u8ff0\u7684\u5185\u5bb9\u3002<\/p>\n<p>\u5f53\u6839\u636e\u8fdc\u7a0b\u8ffd\u8e2a\u5206\u652f\u521b\u5efa\u65b0\u5206\u652f\uff08\u901a\u8fc7\u6267\u884cgit branch\u547d\u4ee4\uff09\u65f6\uff0cGit\u4f1a\u81ea\u52a8\u6dfb\u52a0\u5206\u652f\u9879\u76ee\uff0c\u4ee5\u6307\u793a\u8ffd\u8e2a\u5206\u652f\u5e94\u5408\u5e76\u5230\u65b0\u5206\u652f\u3002<\/p>\n<pre class=\"post-pre\"><code>git branch mydev origin\/master\r\nBranch 'mydev' set up to track remote branch 'master' from 'origin'.\r\n\r\ncat .git\/config\r\n[branch \"mydev\"]\r\n    remote = origin\r\n    merge = refs\/heads\/master\r\n<\/code><\/pre>\n<p>\u5c06rebase\u8bbe\u7f6e\u53d8\u91cf\u8bbe\u4e3atrue\u4ee5\u4f7frebase\u6210\u4e3a\u5206\u652f\u7684\u5e38\u89c4\u4f5c\u4e1a\u3002\u901a\u8fc7rebase\uff0c\u53ef\u4ee5\u4fee\u6539\u4f7f\u5176\u4e0d\u518d\u521b\u5efa\u5408\u5e76\u63d0\u4ea4\u7684\u89c4\u5b9a\uff0c\u5177\u4f53\u89c6\u5f00\u53d1\u51b3\u5b9a\u800c\u5b9a\u3002<\/p>\n<pre class=\"post-pre\"><code>git config branch.mydev.rebase true\r\n[branch \"mydev\"]\r\n    remote = origin\r\n    merge = refs\/heads\/master\r\n    rebase = true\r\n<\/code><\/pre>\n<p>\u30fb\u6dfb\u52a0\u548c\u5220\u9664\u8fdc\u7a0b\u5206\u652f<br \/>\n\u8981\u5728\u8fdc\u7a0b\u5206\u652f\u4e0a\u6267\u884c\u76f8\u540c\u7684\u6dfb\u52a0\u548c\u5220\u9664\u5206\u652f\u64cd\u4f5c\uff0c\u9700\u8981\u4f7f\u7528git push\u547d\u4ee4\u5e76\u6307\u5b9a\u4e0d\u540c\u7684refspec\u3002refspec\u7684\u8bed\u6cd5\u5982\u4e0b\u6240\u793a\u3002<br \/>\n[+]source:destination<\/p>\n<p>\u4f7f\u7528\u4ec5\u5305\u542b\u6765\u6e90\u5f15\u7528\u7684refspec\uff08\u5373\u4e0d\u6307\u5b9a\u76ee\u7684\u5730\uff09\u6267\u884cgit push\u547d\u4ee4\u65f6\uff0c\u5c06\u5728\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5206\u652f\u3002<\/p>\n<pre class=\"post-pre\"><code>cd ~\/public_html\r\ngit branch foo\r\ngit push origin foo\r\nTotal 0 (delta 0), reused 0 (delta 0)\r\nTo \/tmp\/Depot\/public_html.git\/\r\n * [new branch]      foo -&gt; foo\r\n<\/code><\/pre>\n<p>\u5982\u679c\u4f7f\u7528\u53ea\u6709\u76ee\u6807\u53c2\u8003\u7684refspec\uff08\u5373\u4e0d\u6307\u5b9a\u6e90\u7684source\uff09\u6765\u6267\u884cgit push\uff0c\u5219\u4f1a\u4ece\u8fdc\u7a0b\u5b58\u50a8\u5e93\u4e2d\u5220\u9664\u76ee\u6807\u53c2\u8003\u3002\u4e3a\u4e86\u8868\u793a\u53c2\u8003\u662f\u76ee\u6807\u53c2\u8003\uff0c\u5fc5\u987b\u59cb\u7ec8\u6307\u5b9a\u5192\u53f7\u7684\u5206\u9694\u7b26\u3002<\/p>\n<pre class=\"post-pre\"><code>git branch -a\r\n  foo\r\n* master\r\n  mydev\r\n  remotes\/origin\/foo\r\n  remotes\/origin\/master\r\n\r\ngit push origin :foo\r\nTo \/tmp\/Depot\/public_html.git\/\r\n - [deleted]         foo\r\n\r\ngit branch -a\r\n  foo\r\n* master\r\n  mydev\r\n  remotes\/origin\/master\r\n<\/code><\/pre>\n<p>\u8fdc\u7a0b\u8bbe\u7f6e<br \/>\n\u5982\u524d\u6240\u8ff0\uff0cGit\u5c06\u4e0e\u8fdc\u7a0b\u76f8\u5173\u7684\u4fe1\u606f\u8bb0\u5f55\u5728.git\/config\u6587\u4ef6\u4e2d\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7git remote\u547d\u4ee4\u548cgit config\u547d\u4ee4\u8fdb\u884c\u4fee\u6539\uff08\u5f53\u7136\u4e5f\u53ef\u4ee5\u76f4\u63a5\u5728\u7c7b\u4f3cemacs\u7684\u7f16\u8f91\u5668\u4e2d\u8fdb\u884c\u7f16\u8f91\uff09\u3002<\/p>\n<p>git remote\u547d\u4ee4\u662f\u4e13\u95e8\u7528\u4e8e\u8fdc\u7a0b\u64cd\u4f5c\u7684\u547d\u4ee4\uff0c\u53ef\u4ee5\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u7684\u6570\u636e\u3002\u5f53\u8f93\u5165\u7c7b\u4f3cgit remote aaaa\u8fd9\u6837\u7684\u547d\u4ee4\u65f6\uff0c\u4f1a\u663e\u793a\u4f7f\u7528\u8bf4\u660e\u3002<\/p>\n<pre class=\"post-pre\"><code>git remote aaaa\r\nusage: git remote [-v | --verbose]\r\n   or: git remote add [-t &lt;branch&gt;] [-m &lt;master&gt;] [-f] [--tags | --no-tags] [--mirror=&lt;fetch|push&gt;] &lt;name&gt; &lt;url&gt;\r\n   or: git remote rename &lt;old&gt; &lt;new&gt;\r\n   or: git remote remove &lt;name&gt;\r\n   or: git remote set-head &lt;name&gt; (-a | --auto | -d | --delete | &lt;branch&gt;)\r\n   or: git remote [-v | --verbose] show [-n] &lt;name&gt;\r\n   or: git remote prune [-n | --dry-run] &lt;name&gt;\r\n   or: git remote [-v | --verbose] update [-p | --prune] [(&lt;group&gt; | &lt;remote&gt;)...]\r\n   or: git remote set-branches [--add] &lt;name&gt; &lt;branch&gt;...\r\n   or: git remote get-url [--push] [--all] &lt;name&gt;\r\n   or: git remote set-url [--push] &lt;name&gt; &lt;newurl&gt; [&lt;oldurl&gt;]\r\n   or: git remote set-url --add &lt;name&gt; &lt;newurl&gt;\r\n   or: git remote set-url --delete &lt;name&gt; &lt;url&gt;\r\n\r\n    -v, --verbose         be verbose; must be placed before a subcommand\r\n<\/code><\/pre>\n<p>git remote add\u7528\u4e8e\u6dfb\u52a0\u65b0\u7684\u8fdc\u7a0b\u4ed3\u5e93\uff0cgit remote show\u7528\u4e8e\u63d0\u53d6\u8fdc\u7a0b\u4ed3\u5e93\u7684\u4fe1\u606f\uff0cgit remote update\u7528\u4e8e\u5c06\u8fdc\u7a0b\u4ed3\u5e93\u53ef\u7528\u7684\u6240\u6709\u66f4\u65b0\u63d0\u53d6\u5230\u672c\u5730\u4ed3\u5e93\u4e2d\u3002git remote rm\u7528\u4e8e\u4ece\u672c\u5730\u4ed3\u5e93\u4e2d\u5220\u9664\u6307\u5b9a\u7684\u8fdc\u7a0b\u4ed3\u5e93\u53ca\u5176\u76f8\u5173\u7684\u6240\u6709\u8ffd\u8e2a\u5206\u652f\u3002\u5176\u4ed6\u7ec6\u8282\u7684\u547d\u4ee4\u8bf7\u53c2\u9605\u624b\u518c\u3002<\/p>\n<p>\u8981\u5728\u60f3\u8981\u516c\u5f00\u7684\u6240\u6709\u5206\u652f\u4e0a\u4f7f\u7528\u63a8\u9001refspec\u5c06\u540d\u4e3a&#8221;publish&#8221;\u7684\u8fdc\u7a0b\u6dfb\u52a0\u5230\u8fdc\u7a0b\uff0c\u53ef\u4ee5\u6309\u5982\u4e0b\u64cd\u4f5c\uff1a<\/p>\n<pre class=\"post-pre\"><code>git config remote.publish.url 'ssh:\/\/git.example.org\/pub\/repo.git'\r\ngit config remote.publish.push '+refs\/heads\/*:refs\/heads\/*'\r\n<\/code><\/pre>\n<p>\u901a\u8fc7\u6267\u884c\u6b64\u64cd\u4f5c\uff0c.git\/config\u6587\u4ef6\u5c06\u90e8\u5206\u5305\u542b\u4ee5\u4e0b\u8fdc\u7a0b\u5b9a\u4e49\u3002<\/p>\n<pre class=\"post-pre\"><code>[remote \"publish\"]\r\n    url = ssh:\/\/git.example.org\/pub\/repo.git\r\n    merge = +refs\/heads\/*:refs\/heads\/*\r\n<\/code><\/pre>\n<p>\u53e6\u5916\uff0c\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528git config -l \u547d\u4ee4\u5217\u51fa\u914d\u7f6e\u6587\u4ef6\u7684\u5185\u5bb9\u3002<\/p>\n<p>\u6ce8\u610f\u4e8b\u9879\uff1a\u5728\u63a5\u6536 git push \u547d\u4ee4\u65f6\uff0c\u5e94\u6ce8\u610f\u63a5\u6536\u7aef\u4ed3\u5e93\u4e0d\u4f1a\u81ea\u52a8\u68c0\u51fa\u6587\u4ef6\u3002\u5f53\u63a5\u6536\u7aef\u4ed3\u5e93\u4e3a bare \u4ed3\u5e93\u65f6\uff0c\u7531\u4e8e\u6ca1\u6709\u66f4\u65b0\u5de5\u4f5c\u76ee\u5f55\u7684\u64cd\u4f5c\uff0c\u8fd9\u6b63\u662f\u9884\u671f\u7684\u884c\u4e3a\u3002\u7136\u800c\uff0c\u5f53\u63a5\u6536git push\u547d\u4ee4\u7684\u4ed3\u5e93\u662f\u5f00\u53d1\u4ed3\u5e93\u65f6\uff0c\u53ef\u80fd\u4f1a\u51fa\u73b0\u95ee\u9898\u3002\u63a8\u9001\u64cd\u4f5c\u53ef\u80fd\u4f1a\u66f4\u65b0\u8fdc\u7a0b\u4ed3\u5e93\u7684\u72b6\u6001\uff0c\u5305\u62ec HEAD \u63d0\u4ea4\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5373\u4f7f\u8fdc\u7a0b\u5f00\u53d1\u8005\u6ca1\u6709\u8fdb\u884c\u4efb\u4f55\u64cd\u4f5c\uff0c\u5206\u652f\u5f15\u7528\u548c HEAD \u4e5f\u53ef\u80fd\u4f1a\u53d1\u751f\u66f4\u6539\uff0c\u5bfc\u81f4\u68c0\u51fa\u7684\u6587\u4ef6\u548c\u7d22\u5f15\u4e0d\u518d\u540c\u6b65\u3002\u56e0\u6b64\uff0c\u63a8\u8350\u53ea\u5728 bare \u4ed3\u5e93\u4e0a\u6267\u884c git push \u64cd\u4f5c\u3002<\/p>\n<h2>\u8865\u4e01<\/h2>\n<p>\u63d0\u4ea4\u5e76\u540c\u6b65\u5206\u5e03\u5f0f\u5b58\u50a8\u5e93\u7684\u673a\u5236\u4e0d\u4ec5\u9650\u4e8eGit\u539f\u751f\u534f\u8bae\u548cHTTP\u534f\u8bae\u3002\u6709\u65f6\u65e0\u6cd5\u4f7f\u7528\u8fd9\u4e9b\u534f\u8bae\uff0c\u9664\u4e86\u534f\u8bae\u5916\u8fd8\u652f\u6301\u201c\u8865\u4e01\u548c\u5e94\u7528\u201d\u64cd\u4f5c\u3002\u8fd9\u662f\u91c7\u7528\u4e86\u65e9\u671fUnix\u5f00\u53d1\u65f6\u4ee3\u4f7f\u7528\u7684\u65b9\u5f0f\uff0c\u901a\u8fc7\u7535\u5b50\u90ae\u4ef6\u4ea4\u6362\u6570\u636e\u7684\u65b9\u6cd5\u3002<\/p>\n<p>\u5b9e\u65bd\u4e86\u4e09\u4e2a\u7279\u6b8a\u7684\u547d\u4ee4\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">git format-patch\u306f\u3001\u30d1\u30c3\u30c1\u3092\u96fb\u5b50\u30e1\u30fc\u30eb\u5f62\u5f0f\u3067\u751f\u6210\u3059\u308b<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">git send-email\u306f\u3001SMTP\u30d5\u30a3\u30fc\u30c9\u3092\u901a\u3058\u3066\u3001Git\u306e\u30d1\u30c3\u30c1\u3092\u9001\u4fe1\u3059\u308b<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">git am\u306f\u3001\u96fb\u5b50\u30e1\u30fc\u30eb\u4e2d\u306b\u898b\u3064\u304b\u3063\u305f\u30d1\u30c3\u30c1\u3092\u9069\u7528\u3059\u308b<\/ul>\n<p>\u57fa\u672c\u60c5\u666f\u5982\u4e0b\uff1a<br \/>\n\u60a8\u548c\u4e00\u540d\u6216\u591a\u540d\u5f00\u53d1\u4eba\u5458\u6839\u636e\u5171\u540c\u5b58\u50a8\u5e93\u7684\u514b\u9686\u5f00\u59cb\u5171\u540c\u5f00\u53d1\u3002\u60a8\u8fdb\u884c\u67d0\u4e9b\u64cd\u4f5c\u5e76\u5728\u81ea\u5df1\u7684\u5b58\u50a8\u5e93\u526f\u672c\u4e0a\u8fdb\u884c\u4e00\u4e9b\u63d0\u4ea4\u3002\u7136\u540e\uff0c\u901a\u8fc7\u7535\u5b50\u90ae\u4ef6\u5411\u5176\u4ed6\u5f00\u53d1\u4eba\u5458\u53d1\u9001\u60a8\u5e0c\u671b\u5171\u4eab\u7684\u63d0\u4ea4\u3002\u6536\u5230\u90ae\u4ef6\u7684\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u9009\u62e9\u662f\u5426\u5e94\u7528\u8be5\u8865\u4e01\u6216\u662f\u5426\u5e94\u7528\u5176\u4e2d\u4e00\u4e9b\u8865\u4e01\u3002<\/p>\n<p>\u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528\u8865\u4e01\uff1f<br \/>\n\u5c3d\u7ba1Git\u534f\u8bae\u66f4\u9ad8\u6548\uff0c\u4f46\u4f7f\u7528\u8865\u4e01\u7684\u539f\u56e0\u81f3\u5c11\u6709\u4e24\u4e2a\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u3042\u308b\u72b6\u6cc1\u3067\u306f\u3001\u30ea\u30dd\u30b8\u30c8\u30ea\u9593\u3067\u3001\u30d7\u30c3\u30b7\u30e5\u64cd\u4f5c\u3084\u30d7\u30eb\u64cd\u4f5c\u7b49\u3092\u7528\u3044\u3066\u30c7\u30fc\u30bf\u3092\u4ea4\u63db\u3059\u308b\u305f\u3081\u306e\u624b\u6bb5\u3068\u3057\u3066Git\u30cd\u30a4\u30c6\u30a3\u30d6\u30d7\u30ed\u30c8\u30b3\u30eb\u3068HTTP\u30d7\u30ed\u30c8\u30b3\u30eb\u306e\u3069\u3061\u3089\u3082\u4f7f\u7528\u3067\u304d\u306a\u3044\u3053\u3068\u304c\u3042\u308b\u3002\u4f8b\u3048\u3070\u3001\u4f01\u696d\u306e\u30d5\u30a1\u30a4\u30a2\u30a6\u30a9\u30fc\u30eb\u306b\u3088\u3063\u3066\u5916\u90e8\u30b5\u30fc\u30d0\u3078\u306e\u63a5\u7d9a\u3092\u958b\u304f\u3053\u3068\u304c\u3067\u304d\u306a\u3044\u306a\u3069\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u30d4\u30a2\u30c4\u30fc\u30d4\u30a2\u958b\u767a\u30e2\u30c7\u30eb\u306e\u5229\u70b9\u306e1\u3064\u306f\u3001\u5171\u540c\u4f5c\u696d\u3067\u3042\u308b\u3002\u7279\u306b\u3001\u30d1\u30c3\u30c1\u3092\u516c\u958b\u30e1\u30fc\u30ea\u30f3\u30b0\u30ea\u30b9\u30c8\u3078\u9001\u4fe1\u3059\u308b\u3053\u3068\u3067\u3001\u5909\u66f4\u306e\u63d0\u6848\u3092\u516c\u306b\u5e83\u3081\u3001\u67fb\u8aad\u3092\u53d7\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002\u4f8b\u3048\u3070\u76f4\u63a5\u30d7\u30c3\u30b7\u30e5\u3084\u30d7\u30eb\u306a\u3069\u306e\u4fbf\u5229\u306a\u4ea4\u63db\u304c\u3067\u304d\u305f\u3068\u3057\u3066\u3082\u3001\u3042\u3048\u3066\u300c\u30d1\u30c3\u30c1\u3001\u96fb\u5b50\u30e1\u30fc\u30eb\u3001\u30ec\u30d3\u30e5\u30fc\u3001\u9069\u7528\u300d\u306e\u67a0\u7d44\u307f\u3092\u63a1\u7528\u3057\u305f\u3044\u3068\u601d\u3046\u3053\u3068\u3082\u3042\u308b\u304b\u3082\u3057\u308c\u306a\u3044\u3002<\/ul>\n<p>\u751f\u6210\u8865\u4e01<\/p>\n<p>\u4f7f\u7528git format-patch\u547d\u4ee4\u53ef\u4ee5\u751f\u6210\u4ee5\u7535\u5b50\u90ae\u4ef6\u6d88\u606f\u683c\u5f0f\u5c55\u793a\u7684\u8865\u4e01\u3002\u8be5\u547d\u4ee4\u9488\u5bf9\u6307\u5b9a\u7684\u6bcf\u4e2a\u63d0\u4ea4\u521b\u5efa\u4e00\u4e2a\u7535\u5b50\u90ae\u4ef6\u3002<br \/>\n\u901a\u5e38\u7684\u63d0\u4ea4\u6307\u5b9a\u65b9\u5f0f\u5982\u4e0b\uff1a<br \/>\n&#8211; \u6307\u5b9a\u6570\u91cf\u7684\u63d0\u4ea4\uff0c\u4f8b\u5982-2\u3002<br \/>\n&#8211; \u63d0\u4ea4\u8303\u56f4\uff0c\u4f8b\u5982master~4..master~2\u3002<br \/>\n&#8211; \u5355\u4e2a\u63d0\u4ea4\uff0c\u901a\u5e38\u662f\u5206\u652f\u540d\u79f0\uff0c\u5982master\u7b49\u3002<\/p>\n<p>git format-patch\u547d\u4ee4\u7684\u6838\u5fc3\u662fGit\u7684diff\u673a\u5236\uff0c\u5b83\u5728\u4e24\u4e2a\u5173\u952e\u65b9\u9762\u4e0egit diff\u547d\u4ee4\u6709\u6240\u4e0d\u540c\u3002<\/p>\n<p>git diff\u306f\u3001\u9078\u629e\u3055\u308c\u305f\u30b3\u30df\u30c3\u30c8\u5168\u3066\u306e\u7d50\u5408\u3055\u308c\u305f\u5dee\u5206\u306e1\u3064\u306e\u30d1\u30c3\u30c1\u3068\u3057\u3066\u751f\u6210\u3059\u308b\u304c\u3001git format-patch\u306f\u3001\u9078\u629e\u3055\u308c\u305f\u5404\u30b3\u30df\u30c3\u30c8\u306b\u5bfe\u3057\u3066\u30011\u3064\u305a\u3064\u96fb\u5b50\u30e1\u30fc\u30eb\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u751f\u6210\u3059\u308b\u3002<\/p>\n<p>git diff\u306f\u3001\u96fb\u5b50\u30e1\u30fc\u30eb\u306e\u30d8\u30c3\u30c0\u3092\u4f5c\u6210\u3057\u306a\u3044\u3002git format-patch\u306f\u5b9f\u969b\u306e\u5dee\u5206\u306e\u5185\u5bb9\u306b\u52a0\u3048\u3066\u30b3\u30df\u30c3\u30c8\u306e\u4f5c\u8005\u3084\u30b3\u30df\u30c3\u30c8\u65e5\u6642\u3001\u305d\u3057\u3066\u5909\u66f4\u3068\u95a2\u9023\u4ed8\u3051\u3089\u308c\u305f\u30b3\u30df\u30c3\u30c8\u30ed\u30b0\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u4e00\u89a7\u306b\u3057\u305f\u30d8\u30c3\u30c0\u3092\u6301\u3064\u3001\u5b8c\u5168\u306a\u96fb\u5b50\u30e1\u30fc\u30eb\u3092\u751f\u6210\u3059\u308b\u3002<\/p>\n<p>\u4e3a\u4e86\u89c2\u5bdf\u8fd9\u4e2a\u5dee\u5f02\uff0c\u53ef\u4ee5\u6bd4\u8f83\u4f7f\u7528&#8221;git format-patch -1&#8243;\u751f\u6210\u7684\u8865\u4e01\u548c&#8221;git log -p -1 &#8211;pretty=email&#8221;\u8f93\u51fa\u7684\u7ed3\u679c\u3002<\/p>\n<pre class=\"post-pre\"><code>git format-patch -1\r\n0001-F.patch\r\ncat 0001-F.patch\r\nFrom 749aa20326314f9920044b65d28515bf54f8fc2f Mon Sep 17 00:00:00 2001\r\nFrom: git taro &lt;hello@example.com&gt;\r\nDate: Mon, 9 Dec 2019 19:27:53 +0900\r\nSubject: [PATCH] F\r\n\r\n---\r\n file | 1 +\r\n 1 file changed, 1 insertion(+)\r\n\r\ndiff --git a\/file b\/file\r\nindex 6ac15b9..65f21da 100644\r\n--- a\/file\r\n+++ b\/file\r\n@@ -5,3 +5,4 @@ D\r\n X\r\n Y\r\n Z\r\n+F\r\n-- \r\n2.21.0\r\n\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>git log -p -1 --pretty=email\r\nFrom 749aa20326314f9920044b65d28515bf54f8fc2f Mon Sep 17 00:00:00 2001\r\nFrom: git taro &lt;hello@example.com&gt;\r\nDate: Mon, 9 Dec 2019 19:27:53 +0900\r\nSubject: [PATCH] F\r\n\r\n\r\ndiff --git a\/file b\/file\r\nindex 6ac15b9..65f21da 100644\r\n--- a\/file\r\n+++ b\/file\r\n@@ -5,3 +5,4 @@ D\r\n X\r\n Y\r\n Z\r\n+F\r\n\r\n<\/code><\/pre>\n<p>\u552f\u4e00\u7684\u533a\u522b\u5c31\u662f\u6982\u8ff0\u7684\u5386\u53f2\u8bb0\u5f55\u548c\u7248\u672c\u4fe1\u606f\u3002<\/p>\n<h3>\u8865\u4e01\u7684\u5177\u4f53\u5b9e\u4f8b<\/h3>\n<p>\u4ece\u751f\u6210\u8865\u4e01\u7684\u7b80\u5355\u793a\u4f8b\u5f00\u59cb\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nb\">mkdir <\/span>patch\r\ngit init\r\n<span class=\"nb\">echo <\/span>A <span class=\"o\">&gt;<\/span> file\r\ngit add file\r\ngit commit <span class=\"nt\">-mA<\/span>\r\n<span class=\"nb\">echo <\/span>B <span class=\"o\">&gt;&gt;<\/span> file <span class=\"p\">;<\/span> git commit <span class=\"nt\">-mB<\/span> file\r\n<span class=\"nb\">echo <\/span>C <span class=\"o\">&gt;&gt;<\/span> file <span class=\"p\">;<\/span> git commit <span class=\"nt\">-mC<\/span> file\r\n<span class=\"nb\">echo <\/span>D <span class=\"o\">&gt;&gt;<\/span> file <span class=\"p\">;<\/span> git commit <span class=\"nt\">-mD<\/span> file\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>git show-branch --more=4 master\r\n[master] D\r\n[master^] C\r\n[master~2] B\r\n[master~3] A\r\n<\/code><\/pre>\n<p>\u751f\u6210\u4e0e\u6700\u65b0\u7684n\u4e2a\u63d0\u4ea4\u76f8\u5bf9\u5e94\u7684\u8865\u4e01\u7684\u6700\u7b80\u5355\u65b9\u6cd5\u662f\u4f7f\u7528 &#8220;-n&#8221; \u9009\u9879\u3002<\/p>\n<pre class=\"post-pre\"><code>git format-patch -1\r\n0001-D.patch\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>git format-patch -3\r\n0001-B.patch\r\n0002-C.patch\r\n0003-D.patch\r\n<\/code><\/pre>\n<p>\u63a5\u4e0b\u6765\uff0c\u5047\u8bbe\u6211\u4eec\u60f3\u8981\u5c06\u5728B\u548cD\u4e4b\u95f4\u6240\u505a\u7684\u6240\u6709\u66f4\u6539\u4ee5\u8865\u4e01\u7684\u5f62\u5f0f\u53d1\u9001\u3002\u6b64\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4git format-patch master~2..master\u3002<\/p>\n<pre class=\"post-pre\"><code>git format-patch master~2..master\r\n0001-C.patch\r\n0002-D.patch\r\n<\/code><\/pre>\n<p>\u5728\u8fd9\u91cc\uff0c0001-C.patch\u4e2d\u5305\u542b\u4e86B\u548cC\u4e4b\u95f4\u7684\u5dee\u5f02\uff0c0002-D.patch\u4e2d\u5305\u542b\u4e86C\u548cD\u4e4b\u95f4\u7684\u5dee\u5f02\u3002<\/p>\n<pre class=\"post-pre\"><code>cat 0001-C.patch\r\nFrom 2f39214910fb2d71c1c3e837a79f7f80d1380b3e Mon Sep 17 00:00:00 2001\r\nFrom: git taro &lt;hello@example.com&gt;\r\nDate: Mon, 9 Dec 2019 19:12:13 +0900\r\nSubject: [PATCH 1\/2] C\r\n\r\n---\r\n file | 1 +\r\n 1 file changed, 1 insertion(+)\r\n\r\ndiff --git a\/file b\/file\r\nindex 35d242b..b1e6722 100644\r\n--- a\/file\r\n+++ b\/file\r\n@@ -1,2 +1,3 @@\r\n A\r\n B\r\n+C\r\n-- \r\n2.21.0\r\n\r\n<\/code><\/pre>\n<p>\u63a5\u4e0b\u6765\uff0c\u770b\u7b2c\u4e8c\u4e2a\u8865\u4e01\u3002<\/p>\n<pre class=\"post-pre\"><code>cat 0002-D.patch \r\nFrom 7e14a3ff20b322d26415128f6067665e9cd26b39 Mon Sep 17 00:00:00 2001\r\nFrom: git taro &lt;hello@example.com&gt;\r\nDate: Mon, 9 Dec 2019 19:12:37 +0900\r\nSubject: [PATCH 2\/2] D\r\n\r\n---\r\n file | 1 +\r\n 1 file changed, 1 insertion(+)\r\n\r\ndiff --git a\/file b\/file\r\nindex b1e6722..8422d40 100644\r\n--- a\/file\r\n+++ b\/file\r\n@@ -1,3 +1,4 @@\r\n A\r\n B\r\n C\r\n+D\r\n-- \r\n2.21.0\r\n\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>git log --pretty=oneline --abbrev-commit\r\n7e14a3f (HEAD -&gt; master) D\r\n2f39214 C\r\nc26254d B\r\n0d6aac2 A\r\n<\/code><\/pre>\n<p>\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5728\u57fa\u4e8e\u63d0\u4ea4B\u7684\u53e6\u4e00\u4e2a\u5206\u652falt\u4e0a\u8fdb\u884c\u64cd\u4f5c\uff0c\u8fdb\u4e00\u6b65\u590d\u6742\u5316\u60c5\u51b5\u3002\u5728alt\u5206\u652f\u4e0a\uff0c\u6211\u4eec\u4eceB\u5206\u652f\u5f00\u59cb\uff0c\u65b0\u589e\u4e86\u4e09\u4e2a\u63d0\u4ea4X\u3001Y\u548cZ\u3002<\/p>\n<pre class=\"post-pre\"><code>git checkout -b alt c26254d\r\necho X &gt;&gt; ; git commit -mX file\r\necho Y &gt;&gt; ; git commit -mY file\r\necho Z &gt;&gt; ; git commit -mZ file\r\ngit log --graph --pretty=oneline --abbrev-commit --all\r\n* 2ac8c00 (HEAD -&gt; alt) Z\r\n* b12467c Y\r\n* 37f38c6 X\r\n| * 7e14a3f (master) D\r\n| * 2f39214 C\r\n|\/  \r\n* c26254d B\r\n* 0d6aac2 A\r\n<\/code><\/pre>\n<p>\u5047\u8bbemaster\u7684\u5f00\u53d1\u4eba\u5458\u5c06\u63d0\u4ea4Z\u4e2d\u7684alt\u5408\u5e76\u5230\u63d0\u4ea4D\u4e2d\u7684master\uff0c\u5e76\u521b\u5efa\u4e86\u5408\u5e76\u63d0\u4ea4E\u3002<\/p>\n<pre class=\"post-pre\"><code>git checkout master\r\ngit merge alt\r\n<\/code><\/pre>\n<p>\u5728\u8fd9\u91cc\uff0c\u89e3\u51b3\u5e76\u53d1\uff0c\u4ee5\u8fbe\u5230\u4e0b\u4e00\u4e2a\u7ed3\u679c\u3002<\/p>\n<pre class=\"post-pre\"><code>cat file \r\nA\r\nB\r\nC\r\nD\r\nX\r\nY\r\nZ\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>git add file\r\ngit commit -m'All lines'\r\n[master fe4c80f] All lines\r\n\r\necho F &gt;&gt; file ; git commit -mF file\r\n[master 749aa20] F\r\n 1 file changed, 1 insertion(+)\r\n<\/code><\/pre>\n<p>\u6dfb\u52a0\u63d0\u4ea4F\uff0c \u6700\u7ec8\u7684\u63d0\u4ea4\u56fe\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<pre class=\"post-pre\"><code>git log --graph --pretty=oneline --abbrev-commit --all\r\n* 749aa20 (HEAD -&gt; master) F\r\n*   fe4c80f All lines\r\n|\\  \r\n| * 2ac8c00 (alt) Z\r\n| * b12467c Y\r\n| * 37f38c6 X\r\n* | 7e14a3f D\r\n* | 2f39214 C\r\n|\/  \r\n* c26254d B\r\n* 0d6aac2 A\r\n<\/code><\/pre>\n<p>\u5f53\u6307\u5b9a\u63d0\u4ea4\u8303\u56f4\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u662f\u5426\u5305\u542b\u4e86\u5408\u5e76\u64cd\u4f5c\u3002\u4ee5\u5f53\u524d\u4f8b\u5b50\u6765\u8bf4\uff0c\u5728\u8303\u56f4D..F\u4e2d\uff0c\u53ef\u80fd\u4f1a\u542b\u6709All lines\u7684\u63d0\u4ea4E\u548c\u63d0\u4ea4F\uff0c\u4f46\u5b9e\u9645\u4e0a\u5e76\u975e\u5982\u6b64\u3002<\/p>\n<pre class=\"post-pre\"><code>git show-branch --more=10\r\n! [alt] Z\r\n * [master] F\r\n--\r\n * [master] F\r\n+* [alt] Z\r\n+* [alt^] Y\r\n+* [alt~2] X\r\n * [master~2] D\r\n * [master~3] C\r\n+* [master~4] B\r\n+* [master~5] A\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>git format-patch master~2..master\r\n0001-X.patch\r\n0002-Y.patch\r\n0003-Z.patch\r\n0004-F.patch\r\n<\/code><\/pre>\n<p>\u5c3d\u7ba1\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\u6307\u5b9a\u4e86D\u548cF\uff0c\u4f46\u5728\u8865\u4e01\u4e2d\u51fa\u73b0\u7684\u662fX\u3001Y\u3001Z\u3001F\u7684\u63d0\u4ea4\u3002\u63d0\u4ea4\u8303\u56f4\u7684\u5b9a\u4e49\u662f\u4ece\u8303\u56f4\u7ec8\u70b9\u4e4b\u524d\u5305\u62ec\u7684\u6240\u6709\u63d0\u4ea4\u5230\u8303\u56f4\u8d77\u70b9\u4e4b\u524d\u4ee5\u53ca\u8d77\u70b9\u672c\u8eab\u7684\u6240\u6709\u63d0\u4ea4\u4e4b\u5916\u7684\u90e8\u5206\u3002\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u63d0\u4ea4\u8303\u56f4\u662f\u4ece\u6240\u6709\u8d21\u732e\u7ed9F\u7684\u63d0\u4ea4\uff08\u5373\u6240\u6709\u63d0\u4ea4\uff09\u4e2d\u51cf\u53bb\u8d21\u732e\u7ed9D\u548cD\u7684\u63d0\u4ea4\uff08A\u3001B\u3001C\u3001D\uff09\u3002<\/p>\n<p>\u4f5c\u4e3agit format-patch\u7684\u63d0\u4ea4\u8303\u56f4\u53d8\u6362\uff0c\u53ef\u4ee5\u5f15\u7528\u5355\u4e2a\u63d0\u4ea4commit\uff0c\u4f46\u8303\u56f4\u89e3\u91ca\u4e3acommit..HEAD\u3002<\/p>\n<pre class=\"post-pre\"><code>git branch\r\n  alt\r\n* master\r\ngit format-patch master~5\r\n0001-B.patch\r\n0002-C.patch\r\n0003-D.patch\r\n0004-X.patch\r\n0005-Y.patch\r\n0006-Z.patch\r\n0007-F.patch\r\ngit checkout alt\r\nSwitched to branch 'alt'\r\ngit branch\r\n* alt\r\n  master\r\ngit format-patch master~5\r\n0001-B.patch\r\n0002-X.patch\r\n0003-Y.patch\r\n0004-Z.patch\r\n<\/code><\/pre>\n<p>\u5c3d\u7ba1\u6307\u5b9a\u4e86\u76f8\u540c\u7684master~5\uff0c\u4f46\u662f\u53ef\u4ee5\u53d1\u73b0\u7ed3\u679c\u5374\u56e0\u5f53\u524d\u5206\u652f\u800c\u6709\u6240\u4e0d\u540c\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5c3d\u7ba1\u6307\u5b9a\u4e86A commit\uff0c\u4f46\u662f\u65e0\u6cd5\u83b7\u53d6\u5230A commit\u7684\u8865\u4e01\u3002\u6839\u63d0\u4ea4\u662f\u4e00\u4e2a\u7279\u6b8a\u7684\u63d0\u4ea4\uff0c\u5982\u679c\u60f3\u751f\u6210\u4ece\u6700\u521d\u7684\u6839\u63d0\u4ea4\u5230\u6307\u5b9a\u7684end-commit\u63d0\u4ea4\u7684\u6240\u6709\u8865\u4e01\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528&#8211;root\u9009\u9879\u3002<\/p>\n<pre class=\"post-pre\"><code>git format-patch --root master\r\n0001-A.patch\r\n0002-B.patch\r\n0003-C.patch\r\n0004-D.patch\r\n0005-X.patch\r\n0006-Y.patch\r\n0007-Z.patch\r\n0008-F.patch\r\n<\/code><\/pre>\n<p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5f88\u5c11\u4f1a\u5c06\u5355\u4e2a\u63d0\u4ea4\u6307\u5b9a\u7c7b\u4f3c\u4e8ecommit..HEAD\u7684\u65b9\u5f0f\u6765\u5904\u7406\uff0c\u4f46\u5728\u7279\u5b9a\u7684\u60c5\u51b5\u4e0b\u5374\u5f88\u6709\u7528\u3002\u4f8b\u5982\uff0c\u5f53\u6307\u5b9a\u7684\u63d0\u4ea4\u5728\u5f53\u524d\u5206\u652f\u4e0a\u5b58\u5728\uff0c\u4f46\u5728\u4e0d\u540c\u5206\u652f\u4e0a\u4e0d\u5b58\u5728\u65f6\uff0c\u5c06\u751f\u6210\u4e00\u4e2a\u8865\u4e01\uff0c\u8be5\u8865\u4e01\u5728\u5f53\u524d\u5206\u652f\u5b58\u5728\u4f46\u5728\u6307\u5b9a\u7684\u5206\u652f\u4e0a\u4e0d\u5b58\u5728\u3002<\/p>\n<pre class=\"post-pre\"><code>git branch         \r\n  alt\r\n* master\r\ngit format-patch alt\r\n0001-C.patch\r\n0002-D.patch\r\n0003-F.patch\r\n<\/code><\/pre>\n<p>\u53ea\u9700\u8981\u5728master\u4e0a\u6307\u5b9aalt\u5206\u652f\uff0c\u5c31\u53ef\u4ee5\u751f\u6210\u4e3b\u5206\u652f\u4e2d\u5b58\u5728\u4f46alt\u5206\u652f\u4e2d\u4e0d\u5b58\u5728\u7684\u8865\u4e01\u96c6\u5408\u3002\u8fd9\u53ea\u6709\u5728\u6307\u5b9a\u7684\u63d0\u4ea4\u5728\u5176\u4ed6\u5f00\u53d1\u8005\u7684\u8ffd\u8e2a\u5206\u652f\u7684\u9876\u7aef\u65f6\u624d\u80fd\u4f7f\u7528\u3002\u4f8b\u5982\uff0c\u5047\u8bbeAlice\u514b\u9686\u4e86\u4e00\u4e2a\u5b58\u50a8\u5e93\uff0c\u5e76\u57fa\u4e8eAlice\u7684master\u8fdb\u884c\u5f00\u53d1\uff0c\u5219\u4f1a\u6709\u4e00\u4e2a\u7c7b\u4f3c\u4e8eAlice\/master\u7684\u8ffd\u8e2a\u5206\u652f\u3002\u7136\u540e\uff0c\u5728\u81ea\u5df1\u7684master\u5206\u652f\u4e0a\u8fdb\u884c\u4e86\u4e00\u4e9b\u63d0\u4ea4\u540e\uff0c\u53ea\u9700\u5c06\u901a\u8fc7\u547d\u4ee4git format-patch alice\/master\u751f\u6210\u7684\u8865\u4e01\u53d1\u9001\u7ed9Alice\uff0c\u5979\u5c31\u80fd\u5b8c\u5168\u4e86\u89e3\u81ea\u5df1\u7684\u5185\u5bb9\u3002<\/p>\n<p>\u30fb\u8865\u4e01\u548c\u62d3\u6251\u6392\u5e8f<\/p>\n<p>git format-patch\u751f\u6210\u7684\u8865\u4e01\u6309\u7167\u62d3\u6251\u6392\u5e8f\u7684\u987a\u5e8f\u53d1\u51fa\u3002\u6309\u7167\u53d1\u51fa\u7684\u987a\u5e8f\u5e94\u7528\u8fd9\u4e9b\u8865\u4e01\uff0c\u4ed3\u5e93\u5c31\u4f1a\u53d8\u6210\u51c6\u786e\u7684\u72b6\u6001\uff0c\u4f46\u662f\u8fd9\u4e2a\u987a\u5e8f\u6709\u591a\u4e2a\u5019\u9009\u9879\u3002<\/p>\n<pre class=\"post-pre\"><code>A B C D X Y Z E F\r\nA B X Y Z C D E F\r\nA B X C Y D Z E F\r\n<\/code><\/pre>\n<p>\u5982\u679c\u66f4\u52a0\u51c6\u786e\u5730\u63cf\u8ff0\u7684\u8bdd\uff0c\u8bf8\u5982\u6b64\u7c7b\u3002<\/p>\n<pre class=\"post-pre\"><code>A &gt; B\r\nB &gt; C\r\nC &gt; D\r\nD &gt; E\r\nB &gt; X\r\nX &gt; Y\r\nY &gt; Z\r\nZ &gt; E\r\nE &gt; F\r\n<\/code><\/pre>\n<p>\u53ea\u8981\u6ee1\u8db3\u4e86\u8fd9\u4e2a\u9650\u5236\uff0c\u4ed3\u5e93\u5c31\u4f1a\u5904\u4e8e\u51c6\u786e\u7684\u72b6\u6001\u3002<\/p>\n<p>\u5373\u4f7f\u5728\u9009\u62e9\u8be5\u8865\u4e01\u7684\u987a\u5e8f\u65f6\uff0cGit\u4e5f\u4f1a\u5c06\u6240\u6709\u5df2\u9009\u7684\u63d0\u4ea4\u7ebf\u6027\u5316\uff0c\u4e0d\u53d7\u539f\u59cb\u56fe\u5f62\u7684\u590d\u6742\u6027\u6216\u5206\u652f\u7a0b\u5ea6\u7684\u5f71\u54cd\u3002<\/p>\n<h3>\u53d1\u9001\u8865\u4e01\u7684\u7535\u5b50\u90ae\u4ef6<\/h3>\n<p>\u5982\u679c\u60a8\u60f3\u5c06\u751f\u6210\u7684\u8865\u4e01\u6587\u4ef6\u53d1\u9001\u7ed9\u53e6\u4e00\u4e2a\u5f00\u53d1\u4eba\u5458\uff0c\u6709\u4e00\u79cd\u65b9\u6cd5\u53ef\u4ee5\u53d1\u9001\u6587\u4ef6\u3002<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u6267\u884cgit send-email\u7684\u65b9\u6cd5<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u76f4\u63a5\u5f15\u7528\u8865\u4e01\u5230\u90ae\u4ef6\u5ba2\u6237\u7aef\u7684\u65b9\u6cd5<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\u5c06\u8865\u4e01\u5305\u542b\u5728\u7535\u5b50\u90ae\u4ef6\u4e2d\u7684\u65b9\u6cd5<\/ol>\n<p>\u5173\u4e8e\u7b2c\u4e00\u79cd\u65b9\u6cd5\uff0c\u4f8b\u5982\u4f7f\u7528\u547d\u4ee4git send-email -to hello@example.com 0001-A.patch\uff0c\u53ef\u4ee5\u5c06\u540d\u4e3a0001-A.patch\u7684\u8865\u4e01\u53d1\u9001\u5230\u6307\u5b9a\u7684\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u3002\u4f46\u662f\uff0c\u5e73\u65f6\u4e0d\u5e38\u4eceshell\u53d1\u9001\u90ae\u4ef6\u7684\u4eba\u9700\u8981\u8fdb\u884cSMTP\u7b49\u8bbe\u7f6e\u3002<\/p>\n<pre class=\"post-pre\"><code>git config --global sendemail.smtpserver smtp.my-isp.com\r\ngit config --global sendemail.smtpserverport 400\r\n<\/code><\/pre>\n<p>\u8bf7\u641c\u7d22\u8be6\u7ec6\u7684\u8bbe\u7f6e\u65b9\u6cd5\u7b49\u3002<\/p>\n<p>\u5173\u4e8e\u7b2c\u4e8c\u4e2a\u65b9\u6cd5\uff0c<br \/>\n\u6709\u4e9bMUA\uff08\u90ae\u4ef6\u7528\u6237\u4ee3\u7406\uff09\u53ef\u4ee5\u76f4\u63a5\u5c06\u6574\u4e2a\u8865\u4e01\u6587\u4ef6\u6216\u76ee\u5f55\u76f4\u63a5\u5bfc\u5165\u90ae\u4ef6\u6587\u4ef6\u5939\uff0c\u4ee5\u4fbf\u53d1\u9001\u5927\u6587\u4ef6\u8865\u4e01\u6216\u590d\u6742\u7cfb\u5217\u8865\u4e01\u66f4\u52a0\u7b80\u5355\u3002\u4ee5\u4e0b\u793a\u4f8b\u6f14\u793a\u4f7f\u7528git format-patch\u547d\u4ee4\u521b\u5efa\u4f20\u7edfmbox\u683c\u5f0f\u90ae\u4ef6\u6587\u4ef6\u5939\uff0c\u5e76\u5c06\u5176\u76f4\u63a5\u5bfc\u5165\u4f5c\u4e3a\u6d88\u606f\u53d1\u9001\u7a0b\u5e8fmutt\u3002<\/p>\n<pre class=\"post-pre\"><code>git format-patch --stdout master~2..master &gt; mbox\r\nmutt -f mbox\r\n<\/code><\/pre>\n<p>\u8fd9\u4e24\u79cd\u65b9\u6cd5\uff08\u65b9\u6cd51\u548c\u65b9\u6cd52\uff09\u88ab\u63a8\u8350\u4f5c\u4e3a\u8865\u4e01\u7684\u90ae\u4ef6\u53d1\u9001\u65b9\u5f0f\u3002\u8fd9\u4e24\u79cd\u65b9\u5f0f\u90fd\u975e\u5e38\u53ef\u9760\uff0c\u4e14\u5f88\u5c11\u4f1a\u5e72\u6270\u8865\u4e01\u7684\u5185\u5bb9\u3002\u7136\u800c\uff0c\u5982\u679c\u9009\u62e9\u7b2c\u4e09\u79cd\u65b9\u5f0f\uff0c\u6bd4\u5982\u4f7f\u7528Thunderbird\u6216\u8005Gmail\u7b49\u7535\u5b50\u90ae\u4ef6\u5ba2\u6237\u7aef\u65b0\u5efa\u5e76\u53d1\u9001\u90ae\u4ef6\uff0c\u5c31\u9700\u8981\u786e\u4fdd\u8865\u4e01\u7684\u5185\u5bb9\u4e0d\u4f1a\u88ab\u81ea\u52a8\u6362\u884c\u6216\u8005\u8fdb\u884cHTML\u683c\u5f0f\u5316\u3002<\/p>\n<h3>\u5e94\u7528\u8865\u4e01<\/h3>\n<p>\u9664\u4e86git apply\u8fd9\u4e2a\u5e95\u5c42\u547d\u4ee4\uff0cgit am\u7528\u4e8e\u5e94\u7528\u8865\u4e01\u7684\u547d\u4ee4\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5b83\u4f1a\u5728\u5f53\u524d\u5206\u652f\u4e0a\u751f\u6210\u63d0\u4ea4\u3002<\/p>\n<p>\u53e6\u5916\uff0cgit am\u4e2d\u7684am\u662f\u6307\u201c\u4ece\u4e00\u4e2a\u90ae\u7bb1\u4e2d\u5e94\u7528\u4e00\u7cfb\u5217\u8865\u4e01\u201d\u7684\u7f29\u5199\u3002\u60a8\u53ef\u4ee5\u5728\u8fd9\u91cc\u627e\u5230\u6e90\u4ee3\u7801\u3002<\/p>\n<p>\u4f7f\u7528\u5148\u524d\u7684\u4f8b\u5b50\u9032\u884c\u5be6\u9a57\u3002\u5177\u9ad4\u4f86\u8aaa\uff0c\u662f\u5728\u9019\u500b\u63d0\u4ea4\u60c5\u6cc1\u4e0b\u9032\u884c\u3002<\/p>\n<pre class=\"post-pre\"><code>git log --graph --pretty=oneline --abbrev-commit --all\r\n* 749aa20 (HEAD -&gt; master) F\r\n*   fe4c80f All lines\r\n|\\  \r\n| * 2ac8c00 (alt) Z\r\n| * b12467c Y\r\n| * 37f38c6 X\r\n* | 7e14a3f D\r\n* | 2f39214 C\r\n|\/  \r\n* c26254d B\r\n* 0d6aac2 A\r\n<\/code><\/pre>\n<p>\u8fd9\u662f\u7531`git format-patch -o ~\/patches master~5`\u751f\u6210\u7684\u3002<\/p>\n<pre class=\"post-pre\"><code>~\/patches\/0001-B.patch\r\n~\/patches\/0002-C.patch\r\n~\/patches\/0003-D.patch\r\n~\/patches\/0004-X.patch\r\n~\/patches\/0005-Y.patch\r\n~\/patches\/0006-Z.patch\r\n~\/patches\/0007-F.patch\r\n<\/code><\/pre>\n<p>\u4f7f\u7528\u8fd97\u4e2a\u8865\u4e01\uff0c\u5c06\u5176\u5e94\u7528\u5230\u53e6\u4e00\u4e2a\u5b58\u50a8\u5e93\u4e2d\uff08\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5c31\u50cf\u4e0a\u9762\u7684\u4f8b\u5b50\u4e00\u6837\uff0cgit format-patch\u547d\u4ee4\u53ef\u4ee5\u901a\u8fc7-o\u9009\u9879\u521b\u5efa\u4e00\u4e2a\u76ee\u5f55\uff0c\u7136\u540e\u5c06\u8865\u4e01\u653e\u5165\u5176\u4e2d\uff09\u3002<\/p>\n<pre class=\"post-pre\"><code>mkdir am\r\ncd am\r\ngit init\r\nInitialized empty Git repository in ~\/am\/.git\/\r\n\r\necho A &gt;&gt; file\r\ngit add file\r\ngit commit -mA\r\n[master (root-commit) da99743] A\r\n 1 file changed, 1 insertion(+)\r\n create mode 100644 file\r\n<\/code><\/pre>\n<p>\u9996\u5148\u521b\u5efa\u4e00\u4e2a\u5b8c\u5168\u76f8\u540c\u5185\u5bb9\u7684\u65b0\u4ed3\u5e93\u3002\u5982\u679c\u76f4\u63a5\u5e94\u7528git am\u5230\u8be5\u4ed3\u5e93\uff0c\u4f1a\u51fa\u73b0\u95ee\u9898\u3002<\/p>\n<pre class=\"post-pre\"><code>git am ~\/patches\/*\r\nApplying: B\r\nApplying: C\r\nApplying: D\r\nApplying: X\r\nerror: patch failed: file:1\r\nerror: file: patch does not apply\r\nPatch failed at 0004 X\r\nhint: Use 'git am --show-current-patch' to see the failed patch\r\nWhen you have resolved this problem, run \"git am --continue\".\r\nIf you prefer to skip this patch, run \"git am --skip\" instead.\r\nTo restore the original branch and stop patching, run \"git am --abort\".\r\n<\/code><\/pre>\n<p>\u7531\u4e8eGit\u65e0\u6cd5\u8bc6\u522b\u5230\u6709\u4e24\u4e2a\u5206\u652f\u5b58\u5728\uff0c\u6240\u4ee5\u8fd9\u662f\u4e3a\u4ec0\u4e48\u3002\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u786e\u8ba4\u4e00\u4e0b\u5f53\u524d\u7684\u60c5\u51b5\u3002<\/p>\n<pre class=\"post-pre\"><code>git diff\r\n# \u4f55\u3082\u8868\u793a\u3055\u308c\u306a\u3044\r\n\r\ngit show-branch --more=5\r\n[master] D\r\n[master^] C\r\n[master~2] B\r\n[master~3] A\r\n\r\ncat file\r\nA\r\nB\r\nC\r\nD\r\n<\/code><\/pre>\n<p>\u60f3\u8d77\u8d77\u521d\u7684\u4ed3\u5e93\u662f\u8fd9\u6837\u5206\u652f\u7684\u3002<\/p>\n<pre class=\"post-pre\"><code>* 749aa20 (HEAD -&gt; master) F\r\n*   fe4c80f All lines\r\n|\\  \r\n| * 2ac8c00 (alt) Z\r\n| * b12467c Y\r\n| * 37f38c6 X\r\n* | 7e14a3f D\r\n* | 2f39214 C\r\n|\/  \r\n* c26254d B\r\n* 0d6aac2 A\r\n<\/code><\/pre>\n<p>\u53ef\u4ee5\u770b\u51faA\u5230D\u90fd\u88ab\u6b63\u786e\u5e94\u7528\u4e86\u3002\u5e94\u7528git am\u547d\u4ee4\u540e\uff0c\u4f1a\u521b\u5efa.git\/rebase-apply\u76ee\u5f55\u3002\u8be5\u76ee\u5f55\u4e2d\u5305\u542b\u4e86\u4e00\u7cfb\u5217\u8865\u4e01\u4ee5\u53ca\u6bcf\u4e2a\u8865\u4e01\u7684\u5404\u4e2a\u90e8\u5206\u7684\u5404\u79cd\u4fe1\u606f\u3002<\/p>\n<pre class=\"post-pre\"><code>cat .git\/rebase-apply\/patch\r\n---\r\n file | 1 +\r\n 1 file changed, 1 insertion(+)\r\n\r\ndiff --git a\/file b\/file\r\nindex 35d242b..7f9826a 100644\r\n--- a\/file\r\n+++ b\/file\r\n@@ -1,2 +1,3 @@\r\n A\r\n B\r\n+X\r\n-- \r\n2.21.0\r\n\r\n<\/code><\/pre>\n<p>\u76ee\u524d\uff0c\u80fd\u591f\u5e94\u7528X\u7684\u8865\u4e01\u7684\u7248\u672c\u53ea\u6709\u5305\u542bA\u548cB\u7684\u7248\u672c\uff0c\u4f46\u5f53\u524d\u7684\u7248\u672c\u5219\u6db5\u76d6\u4e86\u4eceA\u5230D\u7684\u6240\u6709\u5185\u5bb9\u3002\u6700\u7ec8\u76ee\u6807\u662f\u521b\u5efa\u4e00\u4e2a\u6309\u987a\u5e8f\u6392\u5217\u6240\u6709\u5b57\u7b26\u7684\u6587\u4ef6\uff0c\u7136\u800cGit\u65e0\u6cd5\u81ea\u52a8\u5904\u7406\u6b64\u64cd\u4f5c\u3002Git\u53cb\u5584\u5730\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u7684\u5efa\u8bae\u3002<\/p>\n<pre class=\"post-pre\"><code>hint: Use 'git am --show-current-patch' to see the failed patch\r\nWhen you have resolved this problem, run \"git am --continue\".\r\nIf you prefer to skip this patch, run \"git am --skip\" instead.\r\nTo restore the original branch and stop patching, run \"git am --abort\".\r\n<\/code><\/pre>\n<p>\u7136\u800c\uff0c\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4e0d\u5b58\u5728\u9700\u8981\u89e3\u51b3\u548c\u4fee\u590d\u7684\u6587\u4ef6\u5185\u5bb9\u51b2\u7a81\u3002\u5373\u4f7f\u4f7f\u7528git am &#8211;skip\u547d\u4ee4\uff0c\u6240\u6709\u8ddf\u968fY\u7684\u8865\u4e01\u90fd\u4f1a\u5931\u8d25\u3002\u5f53\u60c5\u51b5\u53d8\u5f97\u7edd\u671b\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u6267\u884cgit am &#8211;abort\u547d\u4ee4\u6765\u6e05\u7406\u7ed3\u679c\u5e76\u6062\u590d\u5230\u539f\u59cb\u5206\u652f\u3002<\/p>\n<p>\u8bf7\u8bb0\u4f4f\uff0c\u63d0\u4ea4X\u5df2\u7ecf\u5e94\u7528\u4e8e\u4ece\u63d0\u4ea4B\u884d\u751f\u51fa\u7684\u65b0\u5206\u652f\u3002\u8fd9\u610f\u5473\u7740\uff0c\u5982\u679c\u8981\u5c06\u8865\u4e01X\u91cd\u65b0\u5e94\u7528\u5230\u8be5\u63d0\u4ea4\u72b6\u6001\u4e0a\uff0c\u5b83\u53ef\u4ee5\u6b63\u786e\u5730\u88ab\u5e94\u7528\u3002<\/p>\n<p>\u8bd5\u7740\u56de\u5230\u63d0\u4ea4A\u7684\u72b6\u6001\uff0c\u5e76\u5c1d\u8bd5\u5e94\u7528B\u548cX\u3002<\/p>\n<pre class=\"post-pre\"><code>git reset <span class=\"nt\">--hard<\/span> master~3\r\ngit reset <span class=\"nt\">--hard<\/span> master~3\r\nHEAD is now at da99743 A\r\n\r\n<span class=\"nb\">rm<\/span> <span class=\"nt\">-rf<\/span> .git\/rebase-apply\/\r\n\r\ngit am ~\/patches\/0001-B.patch\r\nApplying: B\r\ngit am ~\/patches\/0004-X.patch\r\nApplying: X\r\n<\/code><\/pre>\n<p>\u5bf9\u4e8e\u63d0\u4ea4B\uff0c\u63d0\u4ea4X\u6210\u529f\u5730\u5e94\u7528\u4e86\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u901a\u8fc7\u5c06\u8fd9\u4e2a\u57fa\u7840\u6587\u4ef6B\u544a\u8bc9git\uff0c\u95ee\u9898\u5c31\u53ef\u4ee5\u89e3\u51b3\u4e86\u3002<\/p>\n<p>\u7136\u800c\uff0c\u53ef\u80fd\u89c9\u5f97\u5f88\u96be\u786e\u5b9a\u9002\u7528\u5dee\u5f02\u7684\u57fa\u672c\u6587\u4ef6\u3002 Git\u53ef\u4ee5\u5728\u6280\u672f\u4e0a\u8f7b\u677e\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002 \u4ed4\u7ec6\u89c2\u5bdfGit\u751f\u6210\u7684\u8865\u4e01\u548c\u5dee\u5f02\u6587\u4ef6\uff0c\u4f1a\u53d1\u73b0\u9664\u4e86\u4f20\u7edf\u7684Unix diff\u6458\u8981\u5916\uff0c\u8fd8\u6709\u65b0\u7684\u9644\u52a0\u4fe1\u606f\u3002<\/p>\n<pre class=\"post-pre\"><code>cat ~\/patches\/0004-X.patch \r\nFrom 37f38c6b2ccd51394b2d3ab84d2688ff93657718 Mon Sep 17 00:00:00 2001\r\nFrom: git taro &lt;hello@example.com&gt;\r\nDate: Mon, 9 Dec 2019 19:21:53 +0900\r\nSubject: [PATCH 4\/7] X\r\n\r\n---\r\n file | 1 +\r\n 1 file changed, 1 insertion(+)\r\n\r\ndiff --git a\/file b\/file\r\nindex 35d242b..7f9826a 100644\r\n--- a\/file\r\n\r\n+++ b\/file\r\n@@ -1,2 +1,3 @@\r\n A\r\n B\r\n+X\r\n-- \r\n2.21.0\r\n\r\n<\/code><\/pre>\n<p>\u5728\u6587\u4ef6b\/file\u7684\u67d0\u884c\u540e\u9762\uff0c\u53ef\u4ee5\u770b\u5230\u6dfb\u52a0\u4e86\u4e00\u4e2a\u65b0\u7684\u884cindex 35d242b..7f9826a 100644\u3002\u8fd9\u4e2a\u4fe1\u606f\u65e8\u5728\u786e\u4fdd\u6211\u4eec\u80fd\u81ea\u4fe1\u5730\u56de\u7b54\u201c\u8fd9\u4e2a\u8865\u4e01\u53ef\u4ee5\u5e94\u7528\u5728\u54ea\u4e2a\u539f\u59cb\u72b6\u6001\u4e0a\u201d\u7684\u95ee\u9898\u3002<\/p>\n<p>\u7d22\u5f15\u884c\u4e2d\u7684\u7b2c\u4e00\u4e2a\u53f7\u780135d242b\u662f\u6b64\u8865\u4e01\u5e94\u7528\u4e8e\u5bf9\u8c61\u5b58\u50a8\u533a\u57df\u5185Blob\u7684SHA1\u54c8\u5e0c\u503c\u3002\u6362\u53e5\u8bdd\u8bf4\uff0c35d242b\u8868\u793a\u4ec5\u7531\u4e24\u884c\u7ec4\u6210\u7684\u6587\u4ef6\u3002<\/p>\n<pre class=\"post-pre\"><code>git show 35d242b\r\nA\r\nB\r\n<\/code><\/pre>\n<p>\u6709\u529e\u6cd5\u786e\u5b9a\u9002\u7528\u4e8e\u8865\u4e01X\u7684\u7248\u672c\u6587\u4ef6\u3002\u5982\u679c\u4ee3\u7801\u5e93\u4e2d\u5b58\u5728\u8be5\u7248\u672c\u7684\u6587\u4ef6\uff0cGit\u53ef\u4ee5\u5e94\u7528\u8be5\u8865\u4e01\u3002<\/p>\n<p>\u8fd9\u4e2a\u673a\u5236\uff0c\u5373\u5f53\u524d\u6587\u4ef6\u7248\u672c\u3001\u66ff\u4ee3\u7248\u672c\u4ee5\u53ca\u8981\u5e94\u7528\u4fee\u8865\u7a0b\u5e8f\u7684\u57fa\u7840\u7248\u672c\u7684\u51c6\u5907\u673a\u5236\uff0c\u88ab\u79f0\u4e3a3-way\u5408\u5e76\u3002\u5728Git\u4e2d\uff0c\u901a\u8fc7\u5411git am\u547d\u4ee4\u4f20\u9012-3\u6216&#8211;3way\u9009\u9879\uff0c\u53ef\u4ee5\u91cd\u65b0\u6784\u5efa\u8fd9\u4e2a\u573a\u666f\u3002<\/p>\n<p>\u6e05\u7406\u5931\u6557\u7684\u5de5\u4f5c\u5167\u5bb9\u3002\u5c07\u5176\u91cd\u7f6e\u70ba\u6700\u521d\u7684\u63d0\u4ea4\u72c0\u614bA\u3002<\/p>\n<pre class=\"post-pre\"><code>rm -rf .git\/rebase-apply\r\n\r\ngit reset --hard da99743\r\nHEAD is now at da99743 A\r\n\r\ngit am --3way ..\/patches\/*\r\nApplying: B\r\nApplying: C\r\nApplying: D\r\nApplying: X\r\nUsing index info to reconstruct a base tree...\r\nM   file\r\nFalling back to patching base and 3-way merge...\r\nAuto-merging file\r\nCONFLICT (content): Merge conflict in file\r\nerror: Failed to merge in the changes.\r\nPatch failed at 0004 X\r\nhint: Use 'git am --show-current-patch' to see the failed patch\r\nWhen you have resolved this problem, run \"git am --continue\".\r\nIf you prefer to skip this patch, run \"git am --skip\" instead.\r\nTo restore the original branch and stop patching, run \"git am --abort\".\r\n<\/code><\/pre>\n<p>\u5c31\u50cf\u4ee5\u524d\u4e00\u6837\uff0c\u5bf9\u4e8e\u5bf9\u6587\u4ef6\u7684\u7b80\u5355\u4fee\u8865\u7684\u5e94\u7528\u5931\u8d25\u4e86\uff0c\u4f46\u662fGit\u4e0d\u4f1a\u5728\u90a3\u91cc\u505c\u6b62\u5904\u7406\uff0c\u800c\u662f\u8f6c\u800c\u8fdb\u884c3-way\u5408\u5e76\u3002Git\u73b0\u5728\u610f\u8bc6\u5230\u53ef\u4ee5\u6267\u884c\u5408\u5e76\uff0c\u4f46\u7531\u4e8e\u4e24\u4e2a\u4e0d\u540c\u7684\u65b9\u6cd5\u4fee\u6539\u4e86\u91cd\u590d\u7684\u884c\uff0c\u6240\u4ee5\u51b2\u7a81\u4ecd\u7136\u5b58\u5728\u3002<\/p>\n<p>\u7531\u4e8eGit\u65e0\u6cd5\u51c6\u786e\u89e3\u51b3\u6b64\u51b2\u7a81\uff0c\u6240\u4ee5\u6682\u505c\u4e86git am &#8211;3way\u547d\u4ee4\u3002\u5728\u91cd\u65b0\u8f93\u5165\u547d\u4ee4\u4e4b\u524d\uff0c\u9700\u8981\u89e3\u51b3\u51b2\u7a81\u3002<\/p>\n<pre class=\"post-pre\"><code>git status\r\nOn branch master\r\nYou are in the middle of an am session.\r\n  (fix conflicts and then run \"git am --continue\")\r\n  (use \"git am --skip\" to skip this patch)\r\n  (use \"git am --abort\" to restore the original branch)\r\n\r\nUnmerged paths:\r\n  (use \"git reset HEAD &lt;file&gt;...\" to unstage)\r\n  (use \"git add &lt;file&gt;...\" to mark resolution)\r\n\r\n    both modified:   file\r\n\r\nno changes added to commit (use \"git add\" and\/or \"git commit -a\")\r\n\r\ncat file \r\nA\r\nB\r\n&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD\r\nC\r\nD\r\n=======\r\nX\r\n&gt;&gt;&gt;&gt;&gt;&gt;&gt; X\r\n<\/code><\/pre>\n<p>\u5728\u8fd9\u91cc\uff0c\u7531\u4e8e\u6587\u4ef6\u4e2d\u5305\u542b\u4e86\u51b2\u7a81\u5408\u5e76\u7684\u6807\u8bb0\uff0c\u9700\u8981\u4f7f\u7528\u7f16\u8f91\u5668\u6765\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002<\/p>\n<pre class=\"post-pre\"><code>cat file \r\nA\r\nB\r\nC\r\nD\r\nX\r\n<\/code><\/pre>\n<p>\u7ade\u5408\u51b2\u7a81\u89e3\u51b3\u5b8c\u6bd5\u5e76\u5b8c\u6210\u6e05\u7406\u540e\uff0c\u8fd4\u56de\u6267\u884c git am &#8211;3way \u64cd\u4f5c\u3002<\/p>\n<pre class=\"post-pre\"><code>git am --3way --continue\r\nApplying: X\r\nApplying: Y\r\nApplying: Z\r\nUsing index info to reconstruct a base tree...\r\nM   file\r\nFalling back to patching base and 3-way merge...\r\nAuto-merging file\r\nApplying: F\r\n<\/code><\/pre>\n<p>\u8fd9\u5c06\u662f\u6210\u529f\u7684\u4e00\u79cd\u5f62\u5f0f\u3002<\/p>\n<pre class=\"post-pre\"><code>cat file \r\nA\r\nB\r\nC\r\nD\r\nX\r\nY\r\nZ\r\nF\r\n<\/code><\/pre>\n<h2>\u52fe\u4f4f<\/h2>\n<p>\u4f7f\u7528Git\u7684\u94a9\u5b50\uff0c\u53ef\u4ee5\u5728\u5b58\u50a8\u5e93\u4e2d\u7279\u5b9a\u4e8b\u4ef6\u53d1\u751f\uff08\u4f8b\u5982\u63d0\u4ea4\u6216\u4fee\u8865\uff09\u65f6\u6267\u884c\u4e00\u4e2a\u6216\u591a\u4e2a\u4efb\u610f\u811a\u672c\u3002<\/p>\n<p>\u94a9\u5b50\uff08hook\uff09\u88ab\u5173\u8054\u5230\u7279\u5b9a\u7684\u4ee3\u7801\u5e93\u4e2d\uff0c\u5e76\u53ea\u5bf9\u8be5\u4ee3\u7801\u5e93\u8d77\u4f5c\u7528\u3002\u5b83\u4e0d\u4f1a\u901a\u8fc7git clone\u8fdb\u884c\u4f20\u64ad\u548c\u63d0\u4ea4\u3002\u56e0\u6b64\uff0c\u5728\u79c1\u6709\u4ee3\u7801\u5e93\u4e2d\u914d\u7f6e\u7684\u94a9\u5b50\u4e0d\u4f1a\u4f20\u64ad\uff0c\u5e76\u4e14\u4e0d\u4f1a\u6539\u53d8\u65b0\u514b\u9686\u4ee3\u7801\u5e93\u7684\u884c\u4e3a\u3002<\/p>\n<p>\u94a9\u5b50\u6709\u65f6\u53ef\u4ee5\u5728\u5f53\u524d\u7684\u672c\u5730\u4ed3\u5e93\u4e0a\u8fd0\u884c\uff0c\u4e5f\u6709\u65f6\u53ef\u4ee5\u5728\u8fdc\u7a0b\u4ed3\u5e93\u4e0a\u8fd0\u884c\u3002\u4f8b\u5982\uff0c\u5f53\u5c06\u66f4\u6539\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\u65f6\uff0c\u8fdc\u7a0b\u4ed3\u5e93\u7684\u94a9\u5b50\u5c06\u88ab\u6267\u884c\u3002<\/p>\n<p>\u5927\u591a\u6570Git\u7684\u94a9\u5b50\u53ef\u4ee5\u5206\u4e3a\u4ee5\u4e0b\u4e24\u7c7b\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u4e8b\u524d\u30d5\u30c3\u30af\u306f\u3001\u52d5\u4f5c\u304c\u5b8c\u4e86\u3059\u308b\u524d\u306b\u5b9f\u884c\u3055\u308c\u308b\u3002\u3053\u306e\u7a2e\u985e\u306e\u30d5\u30c3\u30af\u306f\u3001\u5909\u66f4\u304c\u9069\u7528\u3055\u308c\u308b\u524d\u306e\u6bb5\u968e\u3067\u3001\u305d\u308c\u3092\u627f\u8a8d\u3057\u305f\u308a\u62d2\u5426\u3057\u305f\u308a\u3001\u307e\u305f\u306f\u8abf\u6574\u3057\u305f\u308a\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3059\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u4e8b\u5f8c\u30d5\u30c3\u30af\u306f\u3001\u52d5\u4f5c\u304c\u5b8c\u4e86\u3057\u305f\u5f8c\u306b\u5b9f\u884c\u3055\u308c\u308b\u3002\u3053\u308c\u306f\u3001\u901a\u77e5\u306e\u5f15\u304d\u91d1\u306b\u3057\u305f\u308a\u3001\u30d3\u30eb\u30c9\u306e\u5b9f\u884c\u3084\u30d0\u30b0\u306e\u30af\u30ed\u30fc\u30ba\u306e\u3088\u3046\u306a\u8ffd\u52a0\u51e6\u7406\u3092\u8d77\u52d5\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3059\u308b\u3002<\/ul>\n<p>\u4e00\u822c\u539f\u5219\u4e0a\uff0c\u5982\u679c\u4e8b\u524d\u94a9\u5b50\u4ee5\u975e0\u72b6\u6001\uff08\u8868\u793a\u901a\u5e38\u5931\u8d25\uff09\u7ed3\u675f\uff0c\u5219Git\u64cd\u4f5c\u5c06\u88ab\u4e2d\u65ad\u3002\u4e8b\u540e\u94a9\u5b50\u7684\u7ed3\u675f\u72b6\u6001\u901a\u5e38\u4f1a\u88ab\u5ffd\u7565\uff0c\u56e0\u4e3a\u5b83\u4e0d\u4f1a\u5bf9\u64cd\u4f5c\u7ed3\u679c\u6216\u5b8c\u6210\u72b6\u6001\u4ea7\u751f\u4efb\u4f55\u8fdb\u4e00\u6b65\u5f71\u54cd\u3002<\/p>\n<p>\u7136\u800c\uff0cGit\u7684\u5f00\u53d1\u8005\u5efa\u8bae\u8c28\u614e\u4f7f\u7528\u94a9\u5b50\u3002\u636e\u4ed6\u4eec\u79f0\uff0c\u94a9\u5b50\u5e94\u8be5\u662f\u6700\u540e\u7684\u624b\u6bb5\uff0c\u53ea\u6709\u5728\u65e0\u6cd5\u901a\u8fc7\u5176\u4ed6\u65b9\u5f0f\u8fbe\u5230\u76f8\u540c\u7ed3\u679c\u7684\u60c5\u51b5\u4e0b\u624d\u5e94\u4f7f\u7528\u3002\u4f8b\u5982\uff0c\u5982\u679c\u6bcf\u6b21\u6267\u884c\u63d0\u4ea4\u6216\u6587\u4ef6\u68c0\u51fa\u3001\u5206\u652f\u751f\u6210\u7b49\u64cd\u4f5c\u65f6\u90fd\u5e0c\u671b\u6307\u5b9a\u7279\u5b9a\u9009\u9879\uff0c\u5219\u65e0\u9700\u4f7f\u7528\u94a9\u5b50\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7Git\u7684\u522b\u540d\u6216\u4f7f\u7528Shell\u811a\u672c\u6765\u6269\u5c55git commit\u7b49\u64cd\u4f5c\u6765\u5b9e\u73b0\u76f8\u540c\u7684\u6548\u679c\u3002<\/p>\n<p>\u4e4d\u4e00\u770b\uff0c\u94a9\u5b50\u4f3c\u4e4e\u662f\u4e00\u79cd\u5177\u6709\u5438\u5f15\u529b\u4e14\u6613\u4e8e\u7406\u89e3\u7684\u65b9\u6cd5\u3002\u7136\u800c\uff0c\u4f7f\u7528\u94a9\u5b50\u4f1a\u5e26\u6765\u5404\u79cd\u4e0d\u540c\u7684\u5f71\u54cd\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30d5\u30c3\u30af\u306fGit\u306e\u6319\u52d5\u3092\u5909\u66f4\u3059\u308b\u3002\u30d5\u30c3\u30af\u306b\u5e38\u8b58\u5916\u308c\u306e\u64cd\u4f5c\u3092\u5b9f\u884c\u3055\u305b\u3066\u3044\u308b\u3068\u3001\u4ed6\u306e\u958b\u767a\u8005\u304c\u3042\u306a\u305f\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u4f7f\u7528\u3057\u305f\u6642\u306b\u9a5a\u3044\u3066\u3057\u307e\u3046\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30d5\u30c3\u30af\u306f\u3001\u672c\u6765\u9ad8\u901f\u306b\u5b9f\u884c\u3067\u304d\u308b\u64cd\u4f5c\u3092\u9045\u304f\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u3002\u4f8b\u3048\u3070\u958b\u767a\u8005\u306f\u8ab0\u304b\u304c\u30b3\u30df\u30c3\u30c8\u3059\u308b\u305f\u3073\u306b\u5358\u4f53\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u3088\u3046\u306a\u30d5\u30c3\u30af\u3092\u5c0e\u5165\u3057\u305f\u3044\u8a98\u60d1\u306b\u99c6\u3089\u308c\u308b\u304c\u3001\u3053\u308c\u306f\u30b3\u30df\u30c3\u30c8\u306e\u901f\u5ea6\u3092\u9045\u304f\u3059\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30d5\u30c3\u30af\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u30d0\u30b0\u3092\u542b\u3093\u3067\u3044\u308b\u3068\u3001\u4f5c\u696d\u3068\u751f\u7523\u6027\u304c\u640d\u306a\u308f\u308c\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u3042\u308b\u30d5\u30c3\u30af\u7fa4\u306f\u3001\u81ea\u52d5\u7684\u306b\u306f\u8907\u88fd\u3055\u308c\u306a\u3044\u3002\u3057\u305f\u304c\u3063\u3066\u3001\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u30b3\u30df\u30c3\u30c8\u30d5\u30c3\u30af\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u5834\u5408\u3001\u305d\u308c\u3092\u4ed6\u306e\u958b\u767a\u8005\u306e\u30b3\u30df\u30c3\u30c8\u306b\u3082\u4f5c\u7528\u3055\u305b\u308b\u3053\u3068\u306f\u3042\u3066\u306b\u3067\u304d\u306a\u3044\u3002<\/ul>\n<p>\u94a9\u5b50\u811a\u672c\u662f\u4ee5\u811a\u672c\u7684\u5f62\u5f0f\u5b58\u5728\u7684\uff0c\u4f4d\u4e8e\u7248\u672c\u5e93\u7684.git\/hooks\u76ee\u5f55\u4e2d\u3002\u6bcf\u4e2a\u94a9\u5b50\u811a\u672c\u90fd\u6709\u4e0e\u5176\u76f8\u5173\u7684\u4e8b\u4ef6\u76f8\u5173\u7684\u540d\u79f0\u3002\u4f8b\u5982\uff0c\u5728\u6267\u884cgit commit\u64cd\u4f5c\u4e4b\u524d\u4f1a\u6267\u884c\u7684\u94a9\u5b50\u811a\u672c\u7684\u540d\u79f0\u4e3a.git\/hooks\/pre-commit\u3002<\/p>\n<p>Fox\u811a\u672c\u9700\u8981\u9075\u5faaUnix\u811a\u672c\u7684\u5e38\u89c4\u89c4\u5219\u3002\u811a\u672c\u5fc5\u987b\u662f\u53ef\u6267\u884c\u7684\uff08\u4f8b\u5982\uff0cchmod a+x .git\/hooks\/pre-commit\uff09\uff0c\u5e76\u4e14\u5fc5\u987b\u4ee5\u6307\u793a\u811a\u672c\u7f16\u5199\u8bed\u8a00\u7684\u884c\u5f00\u5934\uff08\u4f8b\u5982#!\/bin\/bash\u6216#!\/usr\/bin\/perl\uff09\u3002<\/p>\n<h3>\u94a9\u5b50\u7684\u4f7f\u7528\u793a\u4f8b<\/h3>\n<p>\u5982\u679c\u4f60\u6b63\u5728\u4f7f\u7528\u65b0\u7248\u672c\u7684Git\uff08\u5728\u6211\u7684\u73af\u5883\u4e2d\u662fver2.21\uff09\uff0c\u5728\u521b\u5efa\u4ed3\u5e93\u65f6\u53ef\u80fd\u5df2\u7ecf\u6709\u4e00\u4e9b\u94a9\u5b50\u88ab\u521b\u5efa\u4e86\u3002\u5f53\u521b\u5efa\u65b0\u7684\u4ed3\u5e93\u65f6\uff0cGit\u4f1a\u81ea\u52a8\u4ece\u6a21\u677f\u76ee\u5f55\u4e2d\u590d\u5236\u94a9\u5b50\u3002\u5728\u6211\u7684Mac\u4e0a\uff0c\u5b83\u4eec\u4f1a\u88ab\u590d\u5236\u5230\/usr\/local\/git\/share\/git-core\/templates\/hooks\u4e2d\uff08\u5728Ubuntu\u7b49\u5176\u4ed6\u7cfb\u7edf\u4e0a\u53ef\u80fd\u662f\/usr\/share\/git-core\/templates\/hooks\u7b49\u7b49\uff09\u3002<\/p>\n<p>\u4e86\u89e3\u5173\u4e8eHook\u7528\u4f8b\u7684\u4ee5\u4e0b\u8981\u70b9\u662f\u5fc5\u8981\u7684\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u96db\u5f62\u306e\u30d5\u30c3\u30af\u306f\u3001\u305d\u306e\u307e\u307e\u7528\u3044\u308b\u3053\u3068\u306f\u307b\u3068\u3093\u3069\u306a\u3044\u3002\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u8aad\u3093\u3060\u308a\u7de8\u96c6\u3057\u305f\u308a\u3057\u3066\u5b66\u7fd2\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30d5\u30c3\u30af\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u4f5c\u6210\u3055\u308c\u308b\u304c\u3001\u6700\u521d\u306f\u5168\u3066\u7121\u52b9\u306b\u306a\u3063\u3066\u3044\u308b\u3002Mac\u3067\u306f\u3001\u30d5\u30a1\u30a4\u30eb\u540d\u306b.sample\u304c\u8ffd\u52a0\u3055\u308c\u3066\u304a\u308a\u3001\u5b9f\u884c\u53ef\u80fd\u72b6\u614b\u306b\u306a\u3063\u3066\u3044\u308b<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u30d5\u30c3\u30af\u306e\u7528\u4f8b\u3092\u6709\u52b9\u5316\u3059\u308b\u306b\u306f\u3001\u305d\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u304b\u3089\u63a5\u5c3e\u8f9e\u306e.sample\u3092\u524a\u9664\u3057\u3066\uff08mv .git\/hooks\/pre-commit.sample .git\/hooks\/pre-commit\u306a\u3069\uff09\u3001\u5b9f\u884c\u53ef\u80fd\u72b6\u614b\u306b\u3059\u308b\uff08chmod a+x .git\/hooks\/pre-commit\u306a\u3069\uff09\u3002<\/ul>\n<h3>\u94a9\u5b50\u521b\u5efa\u7684\u5b9e\u9645\u4f8b\u5b50<\/h3>\n<pre class=\"post-pre\"><code>mkdir hooktest\r\ncd hooktest\r\ngit init\r\nInitialized empty Git repository in ~\/hooktest\/.git\/\r\n\r\ntouch a b c\r\ngit add a b c\r\ngit commit -m 'added a, b, and c'\r\n[master (root-commit) 404383b] added a, b, and c\r\n 3 files changed, 0 insertions(+), 0 deletions(-)\r\n create mode 100644 a\r\n create mode 100644 b\r\n create mode 100644 c\r\n\r\ncat .git\/hooks\/pre-commit\r\n#!\/bin\/bash\r\necho \"Hello, I'm a pre-commit script!\" &gt;&amp;2\r\nif git diff --cached | grep '^\\+' | grep -q 'broken'; then\r\n   echo \"ERROR: Can't commit the word 'broken'\" &gt;&amp;2\r\n   exit 1 # reject\r\nfi\r\n<\/code><\/pre>\n<p>\u8fd9\u4e2a\u811a\u672c\u4f1a\u5217\u51fa\u6240\u6709\u8981\u63d0\u4ea4\u7684\u5dee\u5f02\uff0c\u5e76\u63d0\u53d6\u65b0\u589e\u7684\u884c\uff08\u4ee5\u201c+\u201d\u5f00\u59cb\u7684\u884c\uff0c\u5373grep &#8216;^\\+&#8217;\u7684\u90e8\u5206\uff09\uff0c\u7136\u540e\u68c0\u67e5\u8fd9\u4e9b\u884c\u4e2d\u662f\u5426\u542b\u6709\u5355\u8bcd\u201c\u635f\u574f\u201d\u3002<\/p>\n<p>\u6709\u8bb8\u591a\u65b9\u6cd5\u53ef\u4ee5\u68c0\u67e5\u5355\u8bcd\u201c\u635f\u574f\u201d\uff0c\u4f46\u663e\u800c\u6613\u89c1\u7684\u65b9\u6cd5\u53ef\u80fd\u4f1a\u9047\u5230\u95ee\u9898\u3002\u5728\u8fd9\u91cc\uff0c\u95ee\u9898\u4e0d\u5728\u4e8e\u5982\u4f55\u201c\u68c0\u67e5\u5355\u8bcd\u2018\u635f\u574f\u2019\u201d\uff0c\u800c\u662f\u5728\u4e8e\u5982\u4f55\u627e\u5230\u8981\u68c0\u67e5\u5355\u8bcd\u201c\u635f\u574f\u201d\u7684\u6587\u672c\u3002<\/p>\n<p>\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u4e0b\u65b9\u6cd5\uff0c\u4f8b\u5982\uff1a<\/p>\n<p>\u5982\u679c git ls-files | xargs grep -q &#8216;broken&#8217; \uff0c\u90a3\u4e48<\/p>\n<p>\u9019\u500b\u64cd\u4f5c\u5c07\u5728\u5b58\u5132\u5eab\u7684\u6240\u6709\u6587\u4ef6\u4e2d\u641c\u5c0b\u55ae\u8a5e\u300cbroken\u300d\u3002\u7136\u800c\uff0c\u9019\u7a2e\u65b9\u6cd5\u5b58\u5728\u5169\u500b\u554f\u984c\u3002\u5982\u679c\u6709\u5176\u4ed6\u4eba\u5df2\u7d93\u63d0\u4ea4\u4e86\u5305\u542b\u55ae\u8a5e\u300cbroken\u300d\u7684\u6587\u4ef6\uff0c\u9019\u500b\u8173\u672c\u5c07\u963b\u6b62\u6240\u6709\u672a\u4f86\u7684\u63d0\u4ea4\u3002\u6b64\u5916\uff0cUnix\u7684grep\u547d\u4ee4\u7121\u6cd5\u77e5\u9053\u54ea\u4e9b\u6587\u4ef6\u5be6\u969b\u4e0a\u8981\u63d0\u4ea4\u3002\u4f8b\u5982\uff0c\u5982\u679c\u5728\u6587\u4ef6b\u4e2d\u6dfb\u52a0\u4e86\u55ae\u8a5e\u300cbroken\u300d\uff0c\u5728a\u4e2d\u9032\u884c\u4e86\u8207\u4e4b\u7121\u95dc\u7684\u66f4\u6539\uff0c\u7136\u5f8c\u57f7\u884cgit commit a\uff0c\u5373\u4f7f\u6c92\u6709\u610f\u5716\u63d0\u4ea4b\uff0c\u9019\u500b\u63d0\u4ea4\u4e5f\u6703\u88ab\u62d2\u7d55\u3002<\/p>\n<p>\u5982\u679c\u8981\u7f16\u5199\u4e00\u4e2a\u9650\u5236\u68c0\u5165\u6388\u6743\u5bf9\u8c61\u7684pre-commit\u811a\u672c\uff0c\u51e0\u4e4e\u53ef\u4ee5\u80af\u5b9a\u7684\u662f\uff0c\u8fdf\u65e9\u4f1a\u9700\u8981\u7ed5\u8fc7\u5b83\u3002\u90a3\u65f6\u5019\uff0c\u53ef\u4ee5\u4f7f\u7528git commit &#8211;no-verify\u9009\u9879\u6765\u64cd\u4f5c\u3002<\/p>\n<pre class=\"post-pre\"><code>chmod a+x .git\/hooks\/pre-commit\r\n\r\necho \"prefectly fine\" &gt; a\r\necho \"broken\" &gt; b\r\ngit commit -m \"test commit -a\" -a\r\nHello, I'm a pre-commit script!\r\nERROR: Can't commit the word 'broken'\r\n\r\ngit commit -m \"test only file a\" a\r\nHello, I'm a pre-commit script!\r\n[master 7b6769f] test only file a\r\n 1 file changed, 1 insertion(+)\r\n\r\ngit commit -m \"test only file b\" b\r\nHello, I'm a pre-commit script!\r\nERROR: Can't commit the word 'broken'\r\n<\/code><\/pre>\n<p>\u5373\u4f7f\u63d0\u4ea4\u6b63\u786e\u8fd0\u884c\uff0cpre-commit\u811a\u672c\u4ecd\u7136\u4f1a\u663e\u793a\u201cHello, I&#8217;m a pre-commit script!\u201d\u8fd9\u4e00\u4fe1\u606f\u3002\u7531\u4e8e\u8fd9\u5728\u5b9e\u9645\u811a\u672c\u4e2d\u53ef\u80fd\u4ee4\u4eba\u56f0\u6270\uff0c\u56e0\u6b64\u5e94\u4ec5\u5728\u8c03\u8bd5\u811a\u672c\u65f6\u4f7f\u7528\u6b64\u7c7b\u6d88\u606f\u3002\u8fd8\u8981\u6ce8\u610f\uff0c\u5f53\u63d0\u4ea4\u88ab\u62d2\u7edd\u65f6\uff0cgit commit\u4e0d\u4f1a\u663e\u793a\u9519\u8bef\u6d88\u606f\u3002\u6b63\u5982\u4f8b\u5b50\u4e2d\u7684\u60c5\u51b5\uff0c\u5f53\u9884\u5904\u7406\u811a\u672c\u8fd4\u56de\u975e\u96f6\u9000\u51fa\u4ee3\u7801\u65f6\uff0c\u5e94\u59cb\u7ec8\u8f93\u51fa\u9519\u8bef\u6d88\u606f\u3002<\/p>\n<h3>\u5229\u7528\u53ef\u7528\u7684\u94a9\u5b50 de<\/h3>\n<p>\u968f\u7740Git\u7684\u53d1\u5c55\uff0c\u65b0\u7c7b\u578b\u7684\u94a9\u5b50\u53ef\u4f9b\u4f7f\u7528\u3002\u5982\u679c\u60f3\u8981\u67e5\u627e\u81ea\u5df1\u7248\u672c\u7684Git\u53ef\u7528\u7684\u94a9\u5b50\uff0c\u53ea\u9700\u8fd0\u884cgit help hooks\u5373\u53ef\u3002<\/p>\n<p>\u4e0e\u63d0\u4ea4\u76f8\u5173\u7684\u6302\u94a9\u3002<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u5982\u679c\u5728\u63d0\u4ea4\u4e4b\u524d\u7684\u94a9\u5b50(pre-commit hook)\u4e2d\u53d1\u73b0\u4e86\u95ee\u9898\uff0c\u53ef\u4ee5\u7acb\u5373\u4e2d\u65ad\u63d0\u4ea4\u3002\u7531\u4e8e\u5728\u8981\u6c42\u7528\u6237\u7f16\u8f91\u63d0\u4ea4\u4fe1\u606f\u4e4b\u524d\u8fd0\u884cpre-commit hook\uff0c\u56e0\u6b64\u4e0d\u4f1a\u51fa\u73b0\u7528\u6237\u8f93\u5165\u4e86\u63d0\u4ea4\u4fe1\u606f\u4f46\u88ab\u62d2\u7edd\u4fee\u6539\u7684\u60c5\u51b5\u3002\u53ef\u4ee5\u5229\u7528\u8fd9\u4e2a\u94a9\u5b50\u81ea\u52a8\u4fee\u6b63\u63d0\u4ea4\u5185\u5bb9\u3002\u5f53\u6307\u5b9a\u4e86&#8211;no-verify\u9009\u9879\u65f6\uff0c\u6b64\u94a9\u5b50\u4e0d\u4f1a\u6267\u884c\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>\u4f7f\u7528prepare-commit-msg hook\u53ef\u4ee5\u5728\u5411\u7528\u6237\u663e\u793aGit\u9ed8\u8ba4\u6d88\u606f\u4e4b\u524d\u8fdb\u884c\u4fee\u6539\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u5229\u7528\u8fd9\u4e2a\u94a9\u5b50\u6765\u66f4\u6539\u9ed8\u8ba4\u7684\u63d0\u4ea4\u6d88\u606f\u6a21\u677f\u3002<\/p>\n<p>\u4f7f\u7528commit-msg hook\u53ef\u4ee5\u5728\u7528\u6237\u7f16\u8f91\u63d0\u4ea4\u6d88\u606f\u540e\u8fdb\u884c\u9a8c\u8bc1\u548c\u4fee\u6539\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u5229\u7528\u8fd9\u4e2a\u94a9\u5b50\u6765\u68c0\u67e5\u62fc\u5199\u9519\u8bef\u6216\u62d2\u7edd\u8d85\u8fc7\u4e00\u5b9a\u884c\u6570\u7684\u6d88\u606f\u3002<\/p>\n<p>post-commit hook\u5728\u5b8c\u6210\u63d0\u4ea4\u64cd\u4f5c\u4e4b\u540e\u6267\u884c\u3002\u6b64\u65f6\uff0c\u53ef\u4ee5\u66f4\u65b0\u65e5\u5fd7\u6587\u4ef6\u3001\u53d1\u9001\u7535\u5b50\u90ae\u4ef6\u6216\u542f\u52a8\u81ea\u52a8\u6784\u5efa\u8fc7\u7a0b\u3002<\/p>\n<p>\u30fb\u4e0e\u8865\u4e01\u76f8\u5173\u7684\u94a9\u5b50<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>applypatch-msg\u662f\u7528\u6765\u68c0\u67e5\u9644\u52a0\u5728\u8865\u4e01\u4e0a\u7684\u63d0\u4ea4\u4fe1\u606f\uff0c\u5e76\u51b3\u5b9a\u662f\u5426\u63a5\u53d7\u7684\u5de5\u5177\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u9009\u62e9\u5728\u6d88\u606f\u4e2d\u6ca1\u6709Signed-off-by\u5934\u90e8\u65f6\u62d2\u7edd\u8865\u4e01\u3002\u6b64\u5916\uff0c\u5728\u6b64\u65f6\u8fd8\u53ef\u4ee5\u4fee\u6539\u63d0\u4ea4\u4fe1\u606f\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>pre-applypatch\u94a9\u5b50\u662f\u5728\u5e94\u7528\u8865\u4e01\u540e\u4f46\u5728\u63d0\u4ea4\u4e4b\u524d\u6267\u884c\u7684\u5de5\u5177\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>post-applypatch\u662f\u5728\u5e94\u7528\u8865\u4e01\u5e76\u63d0\u4ea4\u540e\u6267\u884c\u7684\u5de5\u5177\uff0c\u7c7b\u4f3c\u4e8epost-commit\u811a\u672c\u3002<\/ol>\n<p>\u4e0e\u63a8\u52a8\u76f8\u5173\u7684\u94a9\u5b50<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>pre-recieve\u52fe\u5b50\u7528\u4e8e\u63a5\u6536\u5c06\u8981\u66f4\u65b0\u7684\u6240\u6709\u53c2\u8003\u8d44\u6599\u7684\u5217\u8868\uff0c\u5e76\u63a5\u6536\u5b83\u4eec\u7684\u65b0\u65e7\u5bf9\u8c61\u6307\u9488\u3002\u7531\u4e8epre-recieve\u52fe\u5b50\u53ea\u80fd\u9009\u62e9\u5168\u90e8\u63a5\u53d7\u6216\u5168\u90e8\u62d2\u7edd\u66f4\u6539\uff0c\u56e0\u6b64\u5176\u6709\u6548\u6027\u6709\u9650\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>update\u52fe\u5b50\u5728\u6bcf\u6b21\u53c2\u8003\u8d44\u6599\u66f4\u65b0\u65f6\u90fd\u4f1a\u88ab\u8c03\u7528\u4e00\u6b21\u3002\u5728update\u52fe\u5b50\u4e2d\uff0c\u53ef\u4ee5\u9009\u62e9\u63a5\u53d7\u6216\u62d2\u7edd\u5bf9\u4e2a\u522b\u5206\u652f\u7684\u66f4\u65b0\uff0c\u800c\u4e0d\u5f71\u54cd\u5176\u4ed6\u5206\u652f\u7684\u66f4\u65b0\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>post-receive\u52fe\u5b50\u4e0epre-receive\u52fe\u5b50\u7c7b\u4f3c\uff0c\u53ef\u4ee5\u63a5\u6536\u521a\u521a\u66f4\u65b0\u7684\u6240\u6709\u53c2\u8003\u8d44\u6599\u7684\u5217\u8868\u3002post-receive\u53ef\u4ee5\u505a\u7684\u6240\u6709\u4e8b\u60c5\u90fd\u53ef\u4ee5\u5728update\u52fe\u5b50\u4e2d\u5b8c\u6210\uff0c\u4f46\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0cpost-receive\u53ef\u80fd\u66f4\u4fbf\u5229\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60f3\u8981\u53d1\u9001\u66f4\u65b0\u901a\u77e5\u7684\u7535\u5b50\u90ae\u4ef6\u6d88\u606f\uff0c\u901a\u8fc7\u4f7f\u7528post-receive\uff0c\u53ef\u4ee5\u53d1\u9001\u4e00\u5c01\u5305\u542b\u6240\u6709\u66f4\u65b0\u7684\u901a\u77e5\uff0c\u800c\u4e0d\u662f\u4e3a\u6bcf\u6b21\u66f4\u65b0\u53d1\u9001\u5355\u72ec\u7684\u7535\u5b50\u90ae\u4ef6\u3002<\/ol>\n<p>\u5176\u4ed6\u672c\u5730\u4ed3\u5e93\u7684\u6302\u94a9<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">pre-rebase\u30d5\u30c3\u30af\u306f\u3001\u30d6\u30e9\u30f3\u30c1\u3092\u30ea\u30d9\u30fc\u30b9\u3057\u3088\u3046\u3068\u3057\u305f\u6642\u306b\u5b9f\u884c\u3055\u308c\u308b\u3002\u3053\u308c\u306f\u3001\u65e2\u306b\u516c\u958b\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u306b\u30ea\u30d9\u30fc\u30b9\u3059\u3079\u304d\u3067\u306a\u3044\u30d6\u30e9\u30f3\u30c1\u4e0a\u3067\u8aa4\u3063\u3066git rebase\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u3092\u9632\u3050\u6642\u306b\u4fbf\u5229\u3067\u3042\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">post-checkout\u306f\u3001\u30d6\u30e9\u30f3\u30c1\u3084\u500b\u5225\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u30c1\u30a7\u30c3\u30af\u30a2\u30a6\u30c8\u3057\u305f\u5f8c\u306b\u5b9f\u884c\u3055\u308c\u308b\u3002\u4f8b\u3048\u3070\u3053\u306e\u30d5\u30c3\u30af\u3092\u4f7f\u3063\u3066\u3001\u7a7a\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u81ea\u52d5\u7684\u306b\u4f5c\u6210\u3057\u305f\u308a\u3001\u30c1\u30a7\u30c3\u30af\u30a2\u30a6\u30c8\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u3084\u30a2\u30af\u30bb\u30b9\u5236\u5fa1\u30ea\u30b9\u30c8\u3092\u8a2d\u5b9a\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">post-merge\u306f\u3001\u30de\u30fc\u30b8\u64cd\u4f5c\u3092\u884c\u3063\u305f\u5f8c\u306b\u5b9f\u884c\u3055\u308c\u308b\u3002<\/ul>\n<h2>\u6700\u7ec8<\/h2>\n<p>\u603b\u7ed3\u5230\u6b64\u7ed3\u675f\u3002\u5173\u4e8e\u6700\u65b0\u7684git\u529f\u80fd\uff0c\u8bf7\u53c2\u9605\u53d1\u5e03\u8bf4\u660e\u3002\u5982\u679c\u6709\u65f6\u95f4\uff0c\u5c06\u8fdb\u884c\u8865\u5145\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9996\u5148 \u9019\u7bc7\u6587\u7ae0\u91dd\u5c0d\u5c0d\u65bc\u57fa\u672c\u7684Git\u6307\u4ee4\uff0c\u50cf\u662fgit add\u3001git commit\u3001git push\uff0c\u6211\u5011\u53ef\u80fd\u90fd [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-37543","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Git\u603b\u7ed3 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/git\u603b\u7ed3-3\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Git\u603b\u7ed3\" \/>\n<meta property=\"og:description\" content=\"\u9996\u5148 \u9019\u7bc7\u6587\u7ae0\u91dd\u5c0d\u5c0d\u65bc\u57fa\u672c\u7684Git\u6307\u4ee4\uff0c\u50cf\u662fgit add\u3001git commit\u3001git push\uff0c\u6211\u5011\u53ef\u80fd\u90fd [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/git\u603b\u7ed3-3\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-08-02T07:50:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-29T00:48:23+00:00\" \/>\n<meta name=\"author\" content=\"\u65b0, \u97f5\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u65b0, \u97f5\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"34 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/git%e6%80%bb%e7%bb%93-3\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/git%e6%80%bb%e7%bb%93-3\/\",\"name\":\"Git\u603b\u7ed3 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-08-02T07:50:33+00:00\",\"dateModified\":\"2024-04-29T00:48:23+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/4ba4019495123db3038fd0809e6959c9\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/git%e6%80%bb%e7%bb%93-3\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/git%e6%80%bb%e7%bb%93-3\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/git%e6%80%bb%e7%bb%93-3\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Git\u603b\u7ed3\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/4ba4019495123db3038fd0809e6959c9\",\"name\":\"\u65b0, \u97f5\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d484b6c6e4ae82e8a9efea989e1d2af46d9b6ef128101e63b18f559fca0ae627?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d484b6c6e4ae82e8a9efea989e1d2af46d9b6ef128101e63b18f559fca0ae627?s=96&d=mm&r=g\",\"caption\":\"\u65b0, \u97f5\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/yunxin\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/git%e6%80%bb%e7%bb%93-3\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Git\u603b\u7ed3 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/git\u603b\u7ed3-3\/","og_locale":"zh_CN","og_type":"article","og_title":"Git\u603b\u7ed3","og_description":"\u9996\u5148 \u9019\u7bc7\u6587\u7ae0\u91dd\u5c0d\u5c0d\u65bc\u57fa\u672c\u7684Git\u6307\u4ee4\uff0c\u50cf\u662fgit add\u3001git commit\u3001git push\uff0c\u6211\u5011\u53ef\u80fd\u90fd [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/git\u603b\u7ed3-3\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-08-02T07:50:33+00:00","article_modified_time":"2024-04-29T00:48:23+00:00","author":"\u65b0, \u97f5","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u65b0, \u97f5","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"34 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/git%e6%80%bb%e7%bb%93-3\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/git%e6%80%bb%e7%bb%93-3\/","name":"Git\u603b\u7ed3 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-08-02T07:50:33+00:00","dateModified":"2024-04-29T00:48:23+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/4ba4019495123db3038fd0809e6959c9"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/git%e6%80%bb%e7%bb%93-3\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/git%e6%80%bb%e7%bb%93-3\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/git%e6%80%bb%e7%bb%93-3\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"Git\u603b\u7ed3"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/4ba4019495123db3038fd0809e6959c9","name":"\u65b0, \u97f5","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d484b6c6e4ae82e8a9efea989e1d2af46d9b6ef128101e63b18f559fca0ae627?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d484b6c6e4ae82e8a9efea989e1d2af46d9b6ef128101e63b18f559fca0ae627?s=96&d=mm&r=g","caption":"\u65b0, \u97f5"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/yunxin\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/git%e6%80%bb%e7%bb%93-3\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/37543","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=37543"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/37543\/revisions"}],"predecessor-version":[{"id":84252,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/37543\/revisions\/84252"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=37543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=37543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=37543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}