{"id":21202,"date":"2024-11-19T09:03:58","date_gmt":"2024-11-19T01:03:58","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21202\/"},"modified":"2024-11-19T09:03:58","modified_gmt":"2024-11-19T01:03:58","slug":"git%e6%8f%90%e4%ba%a4%e4%ba%86%e9%94%99%e8%af%af%e7%9a%84%e4%bb%a3%e7%a0%81%e6%80%8e%e4%b9%88%e5%8a%9e","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21202\/","title":{"rendered":"git\u63d0\u4ea4\u4e86\u9519\u8bef\u7684\u4ee3\u7801\u600e\u4e48\u529e"},"content":{"rendered":"<blockquote><p>\n  \u82e5 git \u4e2d\u63d0\u4ea4\u4ee3\u7801\u51fa\u9519\uff0c\u5e94\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\u5904\u7406\uff1a\u8bc6\u522b\u9519\u8bef\uff1a\u4f7f\u7528 git log -1 \u547d\u4ee4\u68c0\u67e5\u6700\u8fd1\u63d0\u4ea4\u3002\u64a4\u9500\u63d0\u4ea4\uff1a\u4f7f\u7528 git reset head~ \u547d\u4ee4\u64a4\u9500\u9519\u8bef\u63d0\u4ea4\u3002\u4fee\u590d\u4ee3\u7801\uff1a\u4fee\u590d\u9519\u8bef\u4ee3\u7801\u5e76\u6d4b\u8bd5\u4fee\u6539\u3002\u91cd\u65b0\u63d0\u4ea4\uff1a\u4f7f\u7528 git add . &amp;&amp; git commit -m &#8220;\u4fee\u590d\u9519\u8bef\u4ee3\u7801&#8221; \u547d\u4ee4\u91cd\u65b0\u63d0\u4ea4\u4fee\u590d\u4ee3\u7801\u3002\u5f3a\u5236\u63a8\u9001\uff08\u53ef\u9009\uff09\uff1a\u5fc5\u8981\u65f6\uff0c\u4f7f\u7528 git push -f origin \u547d\u4ee4\u5f3a\u5236\u63a8\u9001\u63d0\u4ea4\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202404\/09\/2024040911422129421.jpg\" class=\"aligncenter\" title=\"git\u63d0\u4ea4\u4e86\u9519\u8bef\u7684\u4ee3\u7801\u600e\u4e48\u529e\u63d2\u56fe\" alt=\"git\u63d0\u4ea4\u4e86\u9519\u8bef\u7684\u4ee3\u7801\u600e\u4e48\u529e\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5904\u7406\u5df2\u63d0\u4ea4\u7684\u9519\u8bef\u4ee3\u7801<\/strong><\/p>\n<p>\u5728\u4f7f\u7528  \u65f6\uff0c\u4e0d\u53ef\u907f\u514d\u5730\u4f1a\u9047\u5230\u63d0\u4ea4\u9519\u8bef\u4ee3\u7801\u7684\u60c5\u51b5\u3002\u5904\u7406\u6b64\u7c7b\u9519\u8bef\u81f3\u5173\u91cd\u8981\uff0c\u4ee5\u786e\u4fdd\u4ee3\u7801\u5e93\u7684\u5b8c\u6574\u6027\u548c\u7a33\u5b9a\u6027\u3002<\/p>\n<p><strong>\u7b2c\u4e00\u6b65\uff1a\u8bc6\u522b\u9519\u8bef<\/strong><\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u6700\u8fd1\u63d0\u4ea4\u7684\u4ee3\u7801\uff1a<\/p>\n<pre>git log -1<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ed4\u7ec6\u68c0\u67e5\u63d0\u4ea4\u6d88\u606f\u548c\u63d0\u4ea4\u7684\u4ee3\u7801\uff0c\u627e\u51fa\u9519\u8bef\u3002<\/p>\n<p><strong>\u7b2c\u4e8c\u6b65\uff1a\u64a4\u9500\u63d0\u4ea4<\/strong><\/p>\n<p>\u5982\u679c\u9519\u8bef\u5728\u6700\u65b0\u63d0\u4ea4\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u64a4\u9500\uff1a<\/p>\n<pre>git reset HEAD~<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u7b2c\u4e09\u6b65\uff1a\u4fee\u590d\u4ee3\u7801<\/strong><\/p>\n<p>\u4fee\u590d\u63d0\u4ea4\u4e2d\u7684\u9519\u8bef\u4ee3\u7801\u3002\u786e\u4fdd\u4fee\u6539\u540e\u7684\u4ee3\u7801\u5df2\u901a\u8fc7\u6d4b\u8bd5\uff0c\u5e76\u4e14\u4e0d\u4f1a\u5f15\u5165\u65b0\u9519\u8bef\u3002<\/p>\n<p><strong>\u7b2c\u56db\u6b65\uff1a\u91cd\u65b0\u63d0\u4ea4\u4fee\u590d<\/strong><\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u63d0\u4ea4\u4fee\u590d\u540e\u7684\u4ee3\u7801\uff1a<\/p>\n<pre>git add .\ngit commit -m \"\u4fee\u590d\u9519\u8bef\u4ee3\u7801\"<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u7b2c\u4e94\u6b65\uff1a\u5f3a\u5236\u63a8\u9001\uff08\u53ef\u9009\uff09<\/strong><\/p>\n<p>\u5982\u679c\u9700\u8981\u5c06\u4fee\u590d\u63d0\u4ea4\u63a8\u9001\u5230\u8fdc\u7a0b\u5b58\u50a8\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5f3a\u5236\u63a8\u9001\uff1a<\/p>\n<pre>git push -f origin &lt;branch-name&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6ce8\u610f\u4e8b\u9879\uff1a<\/strong><\/p>\n<ul>\n<li>\u4ec5\u5728\u5fc5\u8981\u65f6\u4f7f\u7528\u5f3a\u5236\u63a8\u9001\u3002<\/li>\n<li>\u5728\u5f3a\u5236\u63a8\u9001\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u5df2\u4e0e\u53d7\u5f71\u54cd\u7684\u56e2\u961f\u6210\u5458\u6c9f\u901a\u3002<\/li>\n<li>\u5982\u679c\u9519\u8bef\u5df2\u5408\u5e76\u5230\u5176\u4ed6\u5206\u652f\uff0c\u5219\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u66f4\u590d\u6742\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u4f8b\u5982\u56de\u6eda\u6216 cherry-pick\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u63d0\u4ea4\u4e86\u9519\u8bef\u7684\u4ee3\u7801\u600e\u4e48\u529e\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>\u82e5 git \u4e2d\u63d0\u4ea4\u4ee3\u7801\u51fa\u9519\uff0c\u5e94\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\u5904\u7406\uff1a\u8bc6\u522b\u9519\u8bef\uff1a\u4f7f\u7528 git log -1 \u547d\u4ee4\u68c0\u67e5\u6700\u8fd1\u63d0\u4ea4\u3002\u64a4\u9500\u63d0\u4ea4\uff1a\u4f7f\u7528 git reset head~ \u547d\u4ee4\u64a4\u9500\u9519\u8bef\u63d0\u4ea4\u3002\u4fee\u590d\u4ee3\u7801\uff1a\u4fee\u590d\u9519\u8bef\u4ee3\u7801\u5e76\u6d4b\u8bd5\u4fee\u6539\u3002\u91cd\u65b0\u63d0\u4ea4\uff1a\u4f7f\u7528 git add . &amp;&amp; git commit -m &#8220;\u4fee\u590d\u9519\u8bef\u4ee3\u7801&#8221; \u547d\u4ee4\u91cd\u65b0\u63d0\u4ea4\u4fee\u590d\u4ee3\u7801\u3002\u5f3a\u5236\u63a8\u9001\uff08\u53ef\u9009\uff09\uff1a\u5fc5\u8981\u65f6\uff0c\u4f7f\u7528 git push -f origin \u547d\u4ee4\u5f3a\u5236\u63a8\u9001\u63d0\u4ea4\u3002 \u5982\u4f55\u5904\u7406\u5df2\u63d0\u4ea4\u7684\u9519\u8bef\u4ee3\u7801 \u5728\u4f7f\u7528 \u65f6\uff0c\u4e0d\u53ef\u907f\u514d\u5730\u4f1a\u9047\u5230\u63d0\u4ea4\u9519\u8bef\u4ee3\u7801\u7684\u60c5\u51b5\u3002\u5904\u7406\u6b64\u7c7b\u9519\u8bef\u81f3\u5173\u91cd\u8981\uff0c\u4ee5\u786e\u4fdd\u4ee3\u7801\u5e93\u7684\u5b8c\u6574\u6027\u548c\u7a33\u5b9a\u6027\u3002 \u7b2c\u4e00\u6b65\uff1a\u8bc6\u522b\u9519\u8bef \u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u6700\u8fd1\u63d0\u4ea4\u7684\u4ee3\u7801\uff1a git log -1 \u767b\u5f55\u540e\u590d\u5236 \u4ed4\u7ec6\u68c0\u67e5\u63d0\u4ea4\u6d88\u606f\u548c\u63d0\u4ea4\u7684\u4ee3\u7801\uff0c\u627e\u51fa\u9519\u8bef\u3002 \u7b2c\u4e8c\u6b65\uff1a\u64a4\u9500\u63d0\u4ea4 \u5982\u679c\u9519\u8bef\u5728\u6700\u65b0\u63d0\u4ea4\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u64a4\u9500\uff1a git reset HEAD~ \u767b\u5f55\u540e\u590d\u5236 \u7b2c\u4e09\u6b65\uff1a\u4fee\u590d\u4ee3\u7801 \u4fee\u590d\u63d0\u4ea4\u4e2d\u7684\u9519\u8bef\u4ee3\u7801\u3002\u786e\u4fdd\u4fee\u6539\u540e\u7684\u4ee3\u7801\u5df2\u901a\u8fc7\u6d4b\u8bd5\uff0c\u5e76\u4e14\u4e0d\u4f1a\u5f15\u5165\u65b0\u9519\u8bef\u3002 \u7b2c\u56db\u6b65\uff1a\u91cd\u65b0\u63d0\u4ea4\u4fee\u590d \u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u63d0\u4ea4\u4fee\u590d\u540e\u7684\u4ee3\u7801\uff1a git add . git commit -m &#8220;\u4fee\u590d\u9519\u8bef\u4ee3\u7801&#8221; \u767b\u5f55\u540e\u590d\u5236 \u7b2c\u4e94\u6b65\uff1a\u5f3a\u5236\u63a8\u9001\uff08\u53ef\u9009\uff09 \u5982\u679c\u9700\u8981\u5c06\u4fee\u590d\u63d0\u4ea4\u63a8\u9001\u5230\u8fdc\u7a0b\u5b58\u50a8\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5f3a\u5236\u63a8\u9001\uff1a [&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-21202","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21202","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=21202"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21202\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}