{"id":21189,"date":"2024-11-19T14:48:15","date_gmt":"2024-11-19T06:48:15","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21189\/"},"modified":"2024-11-19T14:48:15","modified_gmt":"2024-11-19T06:48:15","slug":"git%e6%80%8e%e4%b9%88%e5%af%b9%e6%af%94%e4%b8%a4%e4%b8%aa%e7%89%88%e6%9c%ac%e7%9a%84%e6%96%87%e4%bb%b6%e5%a4%a7%e5%b0%8f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21189\/","title":{"rendered":"git\u600e\u4e48\u5bf9\u6bd4\u4e24\u4e2a\u7248\u672c\u7684\u6587\u4ef6\u5927\u5c0f"},"content":{"rendered":"<blockquote><p>\n  \u8981\u5bf9\u6bd4\u4e24\u4e2a git \u7248\u672c\u7684\u6587\u4ef6\u5927\u5c0f\uff0c\u53ef\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a1. \u83b7\u53d6\u6587\u4ef6\u5386\u53f2\u8bb0\u5f55\uff1b2. \u8bc6\u522b\u8981\u5bf9\u6bd4\u7684\u7248\u672c\uff1b3. \u4f7f\u7528 git diff \u5bf9\u6bd4\u6587\u4ef6\u5927\u5c0f\uff1b4. \u67e5\u770b\u6587\u4ef6\u5927\u5c0f\u53d8\u5316\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202404\/09\/2024040911001998929.jpg\" class=\"aligncenter\" title=\"git\u600e\u4e48\u5bf9\u6bd4\u4e24\u4e2a\u7248\u672c\u7684\u6587\u4ef6\u5927\u5c0f\u63d2\u56fe\" alt=\"git\u600e\u4e48\u5bf9\u6bd4\u4e24\u4e2a\u7248\u672c\u7684\u6587\u4ef6\u5927\u5c0f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5bf9\u6bd4\u4e24\u4e2a Git \u7248\u672c\u7684\u6587\u4ef6\u5927\u5c0f<\/strong><\/p>\n<p><strong>\u7b2c\u4e00\u6b65\uff1a\u83b7\u53d6\u6587\u4ef6\u5386\u53f2\u8bb0\u5f55<\/strong><\/p>\n<p>\u4f7f\u7528  log \u547d\u4ee4\u67e5\u770b\u6587\u4ef6\u5386\u53f2\u8bb0\u5f55\uff0c\u8fd9\u5c06\u663e\u793a\u6bcf\u6b21\u63d0\u4ea4\u4e2d\u6587\u4ef6\u7684\u5927\u5c0f\u53d8\u5316\uff1a<\/p>\n<pre>git log --format=\"%H %s %b\" -- &lt;path\/to\/file&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u7b2c\u4e8c\u6b65\uff1a\u8bc6\u522b\u8981\u5bf9\u6bd4\u7684\u7248\u672c<\/strong><\/p>\n<p>\u786e\u5b9a\u8981\u5bf9\u6bd4\u7684\u4e24\u4e2a\u7248\u672c\u3002\u53ef\u4ee5\u4f7f\u7528\u63d0\u4ea4\u54c8\u5e0c\u503c\u6216\u63d0\u4ea4\u6d88\u606f\u6765\u8bc6\u522b\u5b83\u4eec\u3002<\/p>\n<p><strong>\u7b2c\u4e09\u6b65\uff1a\u4f7f\u7528 git diff \u6765\u5bf9\u6bd4\u6587\u4ef6\u5927\u5c0f<\/strong><\/p>\n<p>\u4f7f\u7528 git diff \u547d\u4ee4\u5bf9\u6bd4\u4e24\u4e2a\u7248\u672c\u7684\u6587\u4ef6\u5927\u5c0f\uff1a<\/p>\n<pre>git diff --numstat &lt;commit-hash-1&gt; &lt;commit-hash-2&gt; -- &lt;path\/to\/file&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u663e\u793a\u4e24\u4e2a\u7248\u672c\u4e4b\u95f4\u6587\u4ef6\u5927\u5c0f\u7684\u53d8\u5316\u6458\u8981\uff1a<\/p>\n<ul>\n<li>\u7b2c\u4e00\u884c\u8868\u793a\u65b0\u589e\u7684\u884c\u6570\u548c\u5220\u9664\u7684\u884c\u6570\uff08\u6309\u6b64\u987a\u5e8f\uff09\u3002<\/li>\n<li>\u7b2c\u4e8c\u884c\u8868\u793a\u6587\u4ef6\u603b\u5927\u5c0f\u7684\u53d8\u5316\uff08\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\uff09\u3002<\/li>\n<\/ul>\n<p><strong>\u7b2c\u56db\u6b65\uff1a\u67e5\u770b\u6587\u4ef6\u5927\u5c0f\u53d8\u5316<\/strong><\/p>\n<p>\u5728 git diff \u8f93\u51fa\u4e2d\uff0c\u67e5\u770b\u7b2c\u4e8c\u884c\u7684\u7b2c\u4e8c\u5217\u4ee5\u786e\u5b9a\u6587\u4ef6\u5927\u5c0f\u7684\u53d8\u5316\u3002\u6b63\u503c\u8868\u793a\u6587\u4ef6\u5df2\u589e\u5927\uff0c\u8d1f\u503c\u8868\u793a\u6587\u4ef6\u5df2\u51cf\u5c0f\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u5bf9\u6bd4\u4e24\u4e2a\u7248\u672c\u7684\u6587\u4ef6\u5927\u5c0f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8981\u5bf9\u6bd4\u4e24\u4e2a git \u7248\u672c\u7684\u6587\u4ef6\u5927\u5c0f\uff0c\u53ef\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a1. \u83b7\u53d6\u6587\u4ef6\u5386\u53f2\u8bb0\u5f55\uff1b2. \u8bc6\u522b\u8981\u5bf9\u6bd4\u7684\u7248\u672c\uff1b3. \u4f7f\u7528 git diff \u5bf9\u6bd4\u6587\u4ef6\u5927\u5c0f\uff1b4. \u67e5\u770b\u6587\u4ef6\u5927\u5c0f\u53d8\u5316\u3002 \u5982\u4f55\u5bf9\u6bd4\u4e24\u4e2a Git \u7248\u672c\u7684\u6587\u4ef6\u5927\u5c0f \u7b2c\u4e00\u6b65\uff1a\u83b7\u53d6\u6587\u4ef6\u5386\u53f2\u8bb0\u5f55 \u4f7f\u7528 log \u547d\u4ee4\u67e5\u770b\u6587\u4ef6\u5386\u53f2\u8bb0\u5f55\uff0c\u8fd9\u5c06\u663e\u793a\u6bcf\u6b21\u63d0\u4ea4\u4e2d\u6587\u4ef6\u7684\u5927\u5c0f\u53d8\u5316\uff1a git log &#8211;format=&#8221;%H %s %b&#8221; &#8212; &lt;path\/to\/file&gt; \u767b\u5f55\u540e\u590d\u5236 \u7b2c\u4e8c\u6b65\uff1a\u8bc6\u522b\u8981\u5bf9\u6bd4\u7684\u7248\u672c \u786e\u5b9a\u8981\u5bf9\u6bd4\u7684\u4e24\u4e2a\u7248\u672c\u3002\u53ef\u4ee5\u4f7f\u7528\u63d0\u4ea4\u54c8\u5e0c\u503c\u6216\u63d0\u4ea4\u6d88\u606f\u6765\u8bc6\u522b\u5b83\u4eec\u3002 \u7b2c\u4e09\u6b65\uff1a\u4f7f\u7528 git diff \u6765\u5bf9\u6bd4\u6587\u4ef6\u5927\u5c0f \u4f7f\u7528 git diff \u547d\u4ee4\u5bf9\u6bd4\u4e24\u4e2a\u7248\u672c\u7684\u6587\u4ef6\u5927\u5c0f\uff1a git diff &#8211;numstat &lt;commit-hash-1&gt; &lt;commit-hash-2&gt; &#8212; &lt;path\/to\/file&gt; \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u5c06\u663e\u793a\u4e24\u4e2a\u7248\u672c\u4e4b\u95f4\u6587\u4ef6\u5927\u5c0f\u7684\u53d8\u5316\u6458\u8981\uff1a \u7b2c\u4e00\u884c\u8868\u793a\u65b0\u589e\u7684\u884c\u6570\u548c\u5220\u9664\u7684\u884c\u6570\uff08\u6309\u6b64\u987a\u5e8f\uff09\u3002 \u7b2c\u4e8c\u884c\u8868\u793a\u6587\u4ef6\u603b\u5927\u5c0f\u7684\u53d8\u5316\uff08\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\uff09\u3002 \u7b2c\u56db\u6b65\uff1a\u67e5\u770b\u6587\u4ef6\u5927\u5c0f\u53d8\u5316 \u5728 git diff \u8f93\u51fa\u4e2d\uff0c\u67e5\u770b\u7b2c\u4e8c\u884c\u7684\u7b2c\u4e8c\u5217\u4ee5\u786e\u5b9a\u6587\u4ef6\u5927\u5c0f\u7684\u53d8\u5316\u3002\u6b63\u503c\u8868\u793a\u6587\u4ef6\u5df2\u589e\u5927\uff0c\u8d1f\u503c\u8868\u793a\u6587\u4ef6\u5df2\u51cf\u5c0f\u3002 \u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u5bf9\u6bd4\u4e24\u4e2a\u7248\u672c\u7684\u6587\u4ef6\u5927\u5c0f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-21189","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21189","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=21189"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21189\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}