{"id":21579,"date":"2024-11-19T12:54:23","date_gmt":"2024-11-19T04:54:23","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21579\/"},"modified":"2024-11-19T12:54:23","modified_gmt":"2024-11-19T04:54:23","slug":"git%e6%80%8e%e4%b9%88%e8%8e%b7%e5%8f%96%e5%8e%86%e5%8f%b2%e7%89%88%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21579\/","title":{"rendered":"git\u600e\u4e48\u83b7\u53d6\u5386\u53f2\u7248\u672c"},"content":{"rendered":"<blockquote><p>\n  \u8981\u83b7\u53d6 git \u5386\u53f2\u7248\u672c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u4f7f\u7528 git log \u547d\u4ee4\u67e5\u770b\u63d0\u4ea4\u5386\u53f2\u8bb0\u5f55\uff0c\u5e76\u4f7f\u7528\u9009\u9879\u5b9a\u5236\u8f93\u51fa\u3002\u4f7f\u7528 git diff \u547d\u4ee4\u6bd4\u8f83\u4e24\u4e2a\u7248\u672c\u4e4b\u95f4\u7684\u5dee\u5f02\u3002\u4f7f\u7528 git show \u547d\u4ee4\u67e5\u770b\u63d0\u4ea4\u7684\u8be6\u7ec6\u4fe1\u606f\u3002\u4f7f\u7528 git checkout \u547d\u4ee4\u5207\u6362\u5230\u6307\u5b9a\u7248\u672c\u3002\u4f7f\u7528 git revert \u547d\u4ee4\u56de\u9000\u6307\u5b9a\u7684\u63d0\u4ea4\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/31\/2024053100543510970.jpg\" class=\"aligncenter\" title=\"git\u600e\u4e48\u83b7\u53d6\u5386\u53f2\u7248\u672c\u63d2\u56fe\" alt=\"git\u600e\u4e48\u83b7\u53d6\u5386\u53f2\u7248\u672c\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u83b7\u53d6 Git \u5386\u53f2\u7248\u672c<\/strong><\/p>\n<p>Git \u662f\u4e00\u79cd\u5206\u5e03\u5f0f\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u5f3a\u5927\u7684\u5de5\u5177\u6765\u8ddf\u8e2a\u548c\u7ba1\u7406\u4ee3\u7801\u66f4\u6539\u3002\u8981\u83b7\u53d6 Git \u5386\u53f2\u7248\u672c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<p><strong>1. \u4f7f\u7528 Git Log \u547d\u4ee4<\/strong><\/p>\n<p> log \u547d\u4ee4\u663e\u793a\u63d0\u4ea4\u5386\u53f2\u7684\u5217\u8868\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u9009\u9879\u6765\u5b9a\u5236\u8f93\u51fa\uff1a<\/p>\n<ul>\n<li>&#8211;pretty\uff1a\u6307\u5b9a\u8f93\u51fa\u683c\u5f0f\u3002\u9ed8\u8ba4\u503c\u662f &#8220;medium&#8221;\u3002<\/li>\n<li>-n\uff1a\u9650\u5236\u663e\u793a\u7684\u63d0\u4ea4\u6570\u91cf\u3002<\/li>\n<li>&#8211;author\uff1a\u6309\u4f5c\u8005\u8fc7\u6ee4\u63d0\u4ea4\u3002<\/li>\n<li>&#8211;since \u548c &#8211;until\uff1a\u6309\u65e5\u671f\u8303\u56f4\u8fc7\u6ee4\u63d0\u4ea4\u3002<\/li>\n<\/ul>\n<p>\u4f8b\u5982\uff1a<\/p>\n<pre>git log --pretty=full --since=\"2023-01-01\"<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u4f7f\u7528 Git Diff \u547d\u4ee4<\/strong><\/p>\n<p>git diff \u547d\u4ee4\u663e\u793a\u4e24\u4e2a\u7248\u672c\u4e4b\u95f4\u7684\u5dee\u5f02\u3002\u53ef\u4ee5\u6307\u5b9a\u7248\u672c\u53f7\u6216\u63d0\u4ea4\u54c8\u5e0c\u503c\uff1a<\/p>\n<ul>\n<li>git diff HEAD~1 HEAD\uff1a\u6bd4\u8f83\u5f53\u524d\u63d0\u4ea4\u548c\u4e0a\u4e00\u4e2a\u63d0\u4ea4\u3002<\/li>\n<li>git diff v1.0 v1.1\uff1a\u6bd4\u8f83\u7248\u672c 1.0 \u548c 1.1\u3002<\/li>\n<\/ul>\n<p><strong>3. \u4f7f\u7528 Git Show \u547d\u4ee4<\/strong><\/p>\n<p>git show \u547d\u4ee4\u663e\u793a\u63d0\u4ea4\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u5305\u62ec\u63d0\u4ea4\u6d88\u606f\u3001\u4f5c\u8005\u4fe1\u606f\u548c\u5dee\u5f02\u3002\u53ef\u4ee5\u6307\u5b9a\u63d0\u4ea4\u54c8\u5e0c\u503c\uff1a<\/p>\n<pre>git show commit-hash<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4. \u4f7f\u7528 Git Checkout \u547d\u4ee4<\/strong><\/p>\n<p>git checkout \u547d\u4ee4\u5207\u6362\u5230\u6307\u5b9a\u7248\u672c\u3002\u53ef\u4ee5\u4f7f\u7528\u7248\u672c\u53f7\u6216\u63d0\u4ea4\u54c8\u5e0c\u503c\uff1a<\/p>\n<pre>git checkout v1.0<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>5. \u4f7f\u7528 Git Revert \u547d\u4ee4<\/strong><\/p>\n<p>git revert \u547d\u4ee4\u5c06\u6307\u5b9a\u7684\u63d0\u4ea4\u56de\u9000\u3002\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u63d0\u4ea4\uff0c\u4ee5\u64a4\u6d88\u5148\u524d\u63d0\u4ea4\u6240\u505a\u7684\u66f4\u6539\u3002<\/p>\n<pre>git revert commit-hash<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u83b7\u53d6\u5386\u53f2\u7248\u672c\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\u83b7\u53d6 git \u5386\u53f2\u7248\u672c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u4f7f\u7528 git log \u547d\u4ee4\u67e5\u770b\u63d0\u4ea4\u5386\u53f2\u8bb0\u5f55\uff0c\u5e76\u4f7f\u7528\u9009\u9879\u5b9a\u5236\u8f93\u51fa\u3002\u4f7f\u7528 git diff \u547d\u4ee4\u6bd4\u8f83\u4e24\u4e2a\u7248\u672c\u4e4b\u95f4\u7684\u5dee\u5f02\u3002\u4f7f\u7528 git show \u547d\u4ee4\u67e5\u770b\u63d0\u4ea4\u7684\u8be6\u7ec6\u4fe1\u606f\u3002\u4f7f\u7528 git checkout \u547d\u4ee4\u5207\u6362\u5230\u6307\u5b9a\u7248\u672c\u3002\u4f7f\u7528 git revert \u547d\u4ee4\u56de\u9000\u6307\u5b9a\u7684\u63d0\u4ea4\u3002 \u5982\u4f55\u83b7\u53d6 Git \u5386\u53f2\u7248\u672c Git \u662f\u4e00\u79cd\u5206\u5e03\u5f0f\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u5f3a\u5927\u7684\u5de5\u5177\u6765\u8ddf\u8e2a\u548c\u7ba1\u7406\u4ee3\u7801\u66f4\u6539\u3002\u8981\u83b7\u53d6 Git \u5386\u53f2\u7248\u672c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6b65\u9aa4\uff1a 1. \u4f7f\u7528 Git Log \u547d\u4ee4 log \u547d\u4ee4\u663e\u793a\u63d0\u4ea4\u5386\u53f2\u7684\u5217\u8868\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u9009\u9879\u6765\u5b9a\u5236\u8f93\u51fa\uff1a &#8211;pretty\uff1a\u6307\u5b9a\u8f93\u51fa\u683c\u5f0f\u3002\u9ed8\u8ba4\u503c\u662f &#8220;medium&#8221;\u3002 -n\uff1a\u9650\u5236\u663e\u793a\u7684\u63d0\u4ea4\u6570\u91cf\u3002 &#8211;author\uff1a\u6309\u4f5c\u8005\u8fc7\u6ee4\u63d0\u4ea4\u3002 &#8211;since \u548c &#8211;until\uff1a\u6309\u65e5\u671f\u8303\u56f4\u8fc7\u6ee4\u63d0\u4ea4\u3002 \u4f8b\u5982\uff1a git log &#8211;pretty=full &#8211;since=&#8221;2023-01-01&#8243; \u767b\u5f55\u540e\u590d\u5236 2. \u4f7f\u7528 Git Diff \u547d\u4ee4 git diff \u547d\u4ee4\u663e\u793a\u4e24\u4e2a\u7248\u672c\u4e4b\u95f4\u7684\u5dee\u5f02\u3002\u53ef\u4ee5\u6307\u5b9a\u7248\u672c\u53f7\u6216\u63d0\u4ea4\u54c8\u5e0c\u503c\uff1a git diff [&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-21579","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21579","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=21579"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21579\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21579"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21579"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}