{"id":21216,"date":"2024-11-19T14:26:06","date_gmt":"2024-11-19T06:26:06","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21216\/"},"modified":"2024-11-19T14:26:06","modified_gmt":"2024-11-19T06:26:06","slug":"git%e5%a6%82%e4%bd%95%e5%af%b9%e6%af%94%e4%b8%a4%e4%b8%aa%e7%89%88%e6%9c%ac%e7%9a%84%e5%b7%ae%e5%bc%82","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21216\/","title":{"rendered":"git\u5982\u4f55\u5bf9\u6bd4\u4e24\u4e2a\u7248\u672c\u7684\u5dee\u5f02"},"content":{"rendered":"<blockquote><p>\n  git \u4e2d\u5bf9\u6bd4\u4e24\u4e2a\u7248\u672c\u5dee\u5f02\u7684\u65b9\u6cd5\uff1a\u786e\u5b9a\u8981\u5bf9\u6bd4\u7684\u4e24\u4e2a\u63d0\u4ea4\u7248\u672c\u54c8\u5e0c\u503c\u6216\u6807\u7b7e\u3002\u4f7f\u7528\u547d\u4ee4 git diff \u6765\u5bf9\u6bd4\u63d0\u4ea4\u4e4b\u95f4\u5dee\u5f02\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202404\/09\/2024040912362175757.jpg\" class=\"aligncenter\" title=\"git\u5982\u4f55\u5bf9\u6bd4\u4e24\u4e2a\u7248\u672c\u7684\u5dee\u5f02\u63d2\u56fe\" alt=\"git\u5982\u4f55\u5bf9\u6bd4\u4e24\u4e2a\u7248\u672c\u7684\u5dee\u5f02\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5bf9\u6bd4 Git \u4e2d\u4e24\u4e2a\u7248\u672c\u7684\u5dee\u5f02<\/strong><\/p>\n<p>\u5728 Git \u7248\u672c\u63a7\u5236\u7cfb\u7edf\u4e2d\uff0c\u5bf9\u6bd4\u4e24\u4e2a\u7248\u672c\u7684\u5dee\u5f02\u81f3\u5173\u91cd\u8981\uff0c\u4ee5\u4fbf\u4e86\u89e3\u4ee3\u7801\u5e93\u7684\u53d8\u5316\u3002<\/p>\n<p><strong>\u6b65\u9aa4 1\uff1a\u786e\u5b9a\u7248\u672c<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528  log \u547d\u4ee4\u67e5\u770b\u63d0\u4ea4\u5386\u53f2\u5e76\u786e\u5b9a\u8981\u5bf9\u6bd4\u7684\u4e24\u4e2a\u63d0\u4ea4\u3002<\/li>\n<li>\u4f7f\u7528\u63d0\u4ea4\u54c8\u5e0c\u503c\u6216\u6807\u7b7e\u6765\u6807\u8bc6\u8fd9\u4e9b\u63d0\u4ea4\u3002<\/li>\n<\/ul>\n<p><strong>\u6b65\u9aa4 2\uff1a\u4f7f\u7528 git diff<\/strong><\/p>\n<p>git diff \u547d\u4ee4\u5141\u8bb8\u60a8\u5bf9\u6bd4\u4e24\u4e2a\u63d0\u4ea4\u4e4b\u95f4\u7684\u5dee\u5f02\u3002\u5176\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>git diff &lt;commit1&gt; &lt;commit2&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4f8b\u5982\uff0c\u8981\u5bf9\u6bd4\u63d0\u4ea4 a123 \u548c b456 \u4e4b\u95f4\u7684\u5dee\u5f02\uff0c\u53ef\u4ee5\u4f7f\u7528\uff1a<\/p>\n<pre>git diff a123 b456<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u8f93\u51fa\u89e3\u91ca<\/strong><\/p>\n<p>git diff \u8f93\u51fa\u5c06\u663e\u793a\u4e24\u4e2a\u63d0\u4ea4\u4e4b\u95f4\u7684\u5dee\u5f02\uff0c\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>+\uff1a\u6dfb\u52a0\u5230\u65b0\u63d0\u4ea4\u4e2d\u7684\u884c<\/li>\n<li>-\uff1a\u4ece\u65b0\u63d0\u4ea4\u4e2d\u5220\u9664\u7684\u884c<\/li>\n<li>~\uff1a\u66f4\u6539\u7684\u884c\uff08\u540c\u65f6\u5305\u542b\u6dfb\u52a0\u548c\u5220\u9664\uff09<\/li>\n<\/ul>\n<p><strong>\u9ad8\u7ea7\u9009\u9879<\/strong><\/p>\n<p>git diff \u547d\u4ee4\u8fd8\u63d0\u4f9b\u5176\u4ed6\u9009\u9879\u6765\u5b9a\u5236\u8f93\u51fa\uff1a<\/p>\n<ul>\n<li>&#8211;color\uff1a\u542f\u7528\u989c\u8272\u7f16\u7801\u8f93\u51fa\uff0c\u4ee5\u63d0\u9ad8\u53ef\u8bfb\u6027\u3002<\/li>\n<li>&#8211;stat\uff1a\u4ec5\u663e\u793a\u6dfb\u52a0\u3001\u5220\u9664\u548c\u66f4\u6539\u7684\u6587\u4ef6\u7684\u7edf\u8ba1\u4fe1\u606f\u3002<\/li>\n<li>&#8211;word-diff\uff1a\u9010\u5b57\u6bd4\u8f83\u4e24\u884c\uff0c\u7a81\u51fa\u663e\u793a\u5dee\u5f02\u3002<\/li>\n<\/ul>\n<p><strong>\u4f7f\u7528 GitLab \u6216 GitHub<\/strong><\/p>\n<p>\u5982\u679c\u60a8\u4f7f\u7528 GitLab \u6216 GitHub \u7b49\u5728\u7ebf Git \u5b58\u50a8\u5e93\u670d\u52a1\uff0c\u5b83\u4eec\u8fd8\u63d0\u4f9b\u4fbf\u6377\u7684\u56fe\u5f62\u754c\u9762\u6765\u67e5\u770b\u7248\u672c\u5dee\u5f02\uff1a<\/p>\n<ul>\n<li>\u5728 GitLab \u4e2d\uff0c\u5bfc\u822a\u5230\u63d0\u4ea4\u9875\u9762\u5e76\u627e\u5230\u201cDiff\u201d\u9009\u9879\u5361\u3002<\/li>\n<li>\u5728 GitHub \u4e2d\uff0c\u5bfc\u822a\u5230\u63d0\u4ea4\u9875\u9762\u5e76\u627e\u5230\u201cFiles changed\u201d\u90e8\u5206\u3002<\/li>\n<\/ul>\n<p><strong>\u7ed3\u8bba<\/strong><\/p>\n<p>\u901a\u8fc7\u4f7f\u7528 git diff \u547d\u4ee4\u6216\u5728\u7ebf\u754c\u9762\uff0c\u60a8\u53ef\u4ee5\u8f7b\u677e\u5bf9\u6bd4 Git \u4e2d\u4e24\u4e2a\u7248\u672c\u7684\u5dee\u5f02\u3002\u8fd9\u5bf9\u4e8e\u4e86\u89e3\u4ee3\u7801\u5e93\u4e2d\u7684\u66f4\u6539\u3001\u89e3\u51b3\u51b2\u7a81\u548c\u5ba1\u6838\u4ee3\u7801\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5bf9\u6bd4\u4e24\u4e2a\u7248\u672c\u7684\u5dee\u5f02\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>git \u4e2d\u5bf9\u6bd4\u4e24\u4e2a\u7248\u672c\u5dee\u5f02\u7684\u65b9\u6cd5\uff1a\u786e\u5b9a\u8981\u5bf9\u6bd4\u7684\u4e24\u4e2a\u63d0\u4ea4\u7248\u672c\u54c8\u5e0c\u503c\u6216\u6807\u7b7e\u3002\u4f7f\u7528\u547d\u4ee4 git diff \u6765\u5bf9\u6bd4\u63d0\u4ea4\u4e4b\u95f4\u5dee\u5f02\u3002 \u5982\u4f55\u5bf9\u6bd4 Git \u4e2d\u4e24\u4e2a\u7248\u672c\u7684\u5dee\u5f02 \u5728 Git \u7248\u672c\u63a7\u5236\u7cfb\u7edf\u4e2d\uff0c\u5bf9\u6bd4\u4e24\u4e2a\u7248\u672c\u7684\u5dee\u5f02\u81f3\u5173\u91cd\u8981\uff0c\u4ee5\u4fbf\u4e86\u89e3\u4ee3\u7801\u5e93\u7684\u53d8\u5316\u3002 \u6b65\u9aa4 1\uff1a\u786e\u5b9a\u7248\u672c \u4f7f\u7528 log \u547d\u4ee4\u67e5\u770b\u63d0\u4ea4\u5386\u53f2\u5e76\u786e\u5b9a\u8981\u5bf9\u6bd4\u7684\u4e24\u4e2a\u63d0\u4ea4\u3002 \u4f7f\u7528\u63d0\u4ea4\u54c8\u5e0c\u503c\u6216\u6807\u7b7e\u6765\u6807\u8bc6\u8fd9\u4e9b\u63d0\u4ea4\u3002 \u6b65\u9aa4 2\uff1a\u4f7f\u7528 git diff git diff \u547d\u4ee4\u5141\u8bb8\u60a8\u5bf9\u6bd4\u4e24\u4e2a\u63d0\u4ea4\u4e4b\u95f4\u7684\u5dee\u5f02\u3002\u5176\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b\uff1a git diff &lt;commit1&gt; &lt;commit2&gt; \u767b\u5f55\u540e\u590d\u5236 \u4f8b\u5982\uff0c\u8981\u5bf9\u6bd4\u63d0\u4ea4 a123 \u548c b456 \u4e4b\u95f4\u7684\u5dee\u5f02\uff0c\u53ef\u4ee5\u4f7f\u7528\uff1a git diff a123 b456 \u767b\u5f55\u540e\u590d\u5236 \u8f93\u51fa\u89e3\u91ca git diff \u8f93\u51fa\u5c06\u663e\u793a\u4e24\u4e2a\u63d0\u4ea4\u4e4b\u95f4\u7684\u5dee\u5f02\uff0c\u683c\u5f0f\u5982\u4e0b\uff1a +\uff1a\u6dfb\u52a0\u5230\u65b0\u63d0\u4ea4\u4e2d\u7684\u884c -\uff1a\u4ece\u65b0\u63d0\u4ea4\u4e2d\u5220\u9664\u7684\u884c ~\uff1a\u66f4\u6539\u7684\u884c\uff08\u540c\u65f6\u5305\u542b\u6dfb\u52a0\u548c\u5220\u9664\uff09 \u9ad8\u7ea7\u9009\u9879 git diff \u547d\u4ee4\u8fd8\u63d0\u4f9b\u5176\u4ed6\u9009\u9879\u6765\u5b9a\u5236\u8f93\u51fa\uff1a &#8211;color\uff1a\u542f\u7528\u989c\u8272\u7f16\u7801\u8f93\u51fa\uff0c\u4ee5\u63d0\u9ad8\u53ef\u8bfb\u6027\u3002 &#8211;stat\uff1a\u4ec5\u663e\u793a\u6dfb\u52a0\u3001\u5220\u9664\u548c\u66f4\u6539\u7684\u6587\u4ef6\u7684\u7edf\u8ba1\u4fe1\u606f\u3002 &#8211;word-diff\uff1a\u9010\u5b57\u6bd4\u8f83\u4e24\u884c\uff0c\u7a81\u51fa\u663e\u793a\u5dee\u5f02\u3002 \u4f7f\u7528 GitLab [&hellip;]<\/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-21216","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21216","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=21216"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21216\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}