{"id":21568,"date":"2024-11-19T12:06:11","date_gmt":"2024-11-19T04:06:11","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21568\/"},"modified":"2024-11-19T12:06:11","modified_gmt":"2024-11-19T04:06:11","slug":"git%e6%80%8e%e4%b9%88%e6%92%a4%e9%94%80commit","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21568\/","title":{"rendered":"git\u600e\u4e48\u64a4\u9500commit"},"content":{"rendered":"<blockquote><p>\n  \u9488\u5bf9\u4e0d\u540c\u573a\u666f\uff0c\u64a4\u9500 git \u63d0\u4ea4\u7684\u65b9\u6cd5\uff1a\u64a4\u9500\u6700\u8fd1\u4e00\u6b21\u63d0\u4ea4\uff1agit reset &#8211;soft head~1\u64a4\u9500\u6240\u6709\u63d0\u4ea4\uff1agit reset &#8211;hard (\u6ce8\u610f\u6b64\u64cd\u4f5c\u4e0d\u53ef\u9006)\u64a4\u9500\u7279\u5b9a\u63d0\u4ea4\uff1agit reset &#8211;hard \u64a4\u9500\u5df2\u63a8\u9001\u7684\u63d0\u4ea4\uff1a\u5728\u672c\u5730\u521b\u5efa\u65b0\u5206\u652f + \u91cd\u5199\u63d0\u4ea4 + \u5f3a\u5236\u63a8\u9001\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/31\/2024053100122579892.jpg\" class=\"aligncenter\" title=\"git\u600e\u4e48\u64a4\u9500commit\u63d2\u56fe\" alt=\"git\u600e\u4e48\u64a4\u9500commit\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u64a4\u9500 Git \u63d0\u4ea4<\/strong><\/p>\n<p><strong>\u76f4\u63a5\u64a4\u9500\u6700\u8fd1\u4e00\u6b21\u63d0\u4ea4<\/strong><\/p>\n<p>\u4f7f\u7528  reset &#8211;soft HEAD~1 \u547d\u4ee4\uff0c\u53ef\u4ee5\u64a4\u9500\u6700\u8fd1\u4e00\u6b21\u63d0\u4ea4\uff0c\u4f46\u4fdd\u7559\u5df2\u6682\u5b58\u7684\u66f4\u6539\u3002<\/p>\n<p><strong>\u64a4\u9500\u6240\u6709\u63d0\u4ea4<\/strong><\/p>\n<p>\u82e5\u8981\u64a4\u9500\u6240\u6709\u63d0\u4ea4\uff0c\u53ef\u4ee5\u4f7f\u7528 git reset &#8211;hard \u547d\u4ee4\u3002\u4f46\u8bf7\u6ce8\u610f\uff0c\u8fd9\u5c06\u4e22\u5931\u6240\u6709\u672a\u6682\u5b58\u7684\u66f4\u6539\u3002<\/p>\n<p><strong>\u64a4\u9500\u7279\u5b9a\u63d0\u4ea4<\/strong><\/p>\n<p>\u82e5\u8981\u64a4\u9500\u7279\u5b9a\u63d0\u4ea4\uff0c\u53ef\u4ee5\u4f7f\u7528 git reset &#8211;hard \u547d\u4ee4\uff0c\u5176\u4e2d \u662f\u8981\u64a4\u9500\u7684\u63d0\u4ea4\u7684\u54c8\u5e0c\u503c\u3002 <\/p>\n<p><strong>\u64a4\u9500\u5df2\u63a8\u9001\u7684\u63d0\u4ea4<\/strong><\/p>\n<p>\u82e5\u8981\u64a4\u9500\u5df2\u63a8\u9001\u7684\u63d0\u4ea4\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\u5728\u672c\u5730\u521b\u5efa\u4e00\u4e2a\u65b0\u5206\u652f\uff1agit checkout -b new-branch<\/li>\n<li>\u91cd\u5199\u8981\u64a4\u9500\u7684\u63d0\u4ea4\uff1agit commit &#8211;amend<\/li>\n<li>\u5f3a\u884c\u63a8\u9001\u65b0\u5206\u652f\uff1agit push -f origin new-branch<\/li>\n<\/ol>\n<p><strong>\u6ce8\u610f\u4e8b\u9879<\/strong><\/p>\n<ul>\n<li>\u5728\u4f7f\u7528 git reset &#8211;hard \u547d\u4ee4\u4e4b\u524d\uff0c\u52a1\u5fc5\u5907\u4efd\u60a8\u7684\u66f4\u6539\u3002<\/li>\n<li>\u64a4\u9500\u63d0\u4ea4\u540e\uff0c\u60a8\u9700\u8981\u518d\u6b21\u63d0\u4ea4\u66f4\u6539\u624d\u80fd\u5c06\u5176\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\u3002<\/li>\n<li>\u5982\u679c\u60a8\u4e0e\u4ed6\u4eba\u5408\u4f5c\uff0c\u8bf7\u786e\u4fdd\u5728\u64a4\u9500\u63d0\u4ea4\u4e4b\u524d\u901a\u77e5\u4ed6\u4eec\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u64a4\u9500commit\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>\u9488\u5bf9\u4e0d\u540c\u573a\u666f\uff0c\u64a4\u9500 git \u63d0\u4ea4\u7684\u65b9\u6cd5\uff1a\u64a4\u9500\u6700\u8fd1\u4e00\u6b21\u63d0\u4ea4\uff1agit reset &#8211;soft head~1\u64a4\u9500\u6240\u6709\u63d0\u4ea4\uff1agit reset &#8211;hard (\u6ce8\u610f\u6b64\u64cd\u4f5c\u4e0d\u53ef\u9006)\u64a4\u9500\u7279\u5b9a\u63d0\u4ea4\uff1agit reset &#8211;hard \u64a4\u9500\u5df2\u63a8\u9001\u7684\u63d0\u4ea4\uff1a\u5728\u672c\u5730\u521b\u5efa\u65b0\u5206\u652f + \u91cd\u5199\u63d0\u4ea4 + \u5f3a\u5236\u63a8\u9001 \u5982\u4f55\u64a4\u9500 Git \u63d0\u4ea4 \u76f4\u63a5\u64a4\u9500\u6700\u8fd1\u4e00\u6b21\u63d0\u4ea4 \u4f7f\u7528 reset &#8211;soft HEAD~1 \u547d\u4ee4\uff0c\u53ef\u4ee5\u64a4\u9500\u6700\u8fd1\u4e00\u6b21\u63d0\u4ea4\uff0c\u4f46\u4fdd\u7559\u5df2\u6682\u5b58\u7684\u66f4\u6539\u3002 \u64a4\u9500\u6240\u6709\u63d0\u4ea4 \u82e5\u8981\u64a4\u9500\u6240\u6709\u63d0\u4ea4\uff0c\u53ef\u4ee5\u4f7f\u7528 git reset &#8211;hard \u547d\u4ee4\u3002\u4f46\u8bf7\u6ce8\u610f\uff0c\u8fd9\u5c06\u4e22\u5931\u6240\u6709\u672a\u6682\u5b58\u7684\u66f4\u6539\u3002 \u64a4\u9500\u7279\u5b9a\u63d0\u4ea4 \u82e5\u8981\u64a4\u9500\u7279\u5b9a\u63d0\u4ea4\uff0c\u53ef\u4ee5\u4f7f\u7528 git reset &#8211;hard \u547d\u4ee4\uff0c\u5176\u4e2d \u662f\u8981\u64a4\u9500\u7684\u63d0\u4ea4\u7684\u54c8\u5e0c\u503c\u3002 \u64a4\u9500\u5df2\u63a8\u9001\u7684\u63d0\u4ea4 \u82e5\u8981\u64a4\u9500\u5df2\u63a8\u9001\u7684\u63d0\u4ea4\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6b65\u9aa4\uff1a \u5728\u672c\u5730\u521b\u5efa\u4e00\u4e2a\u65b0\u5206\u652f\uff1agit checkout -b new-branch \u91cd\u5199\u8981\u64a4\u9500\u7684\u63d0\u4ea4\uff1agit commit &#8211;amend \u5f3a\u884c\u63a8\u9001\u65b0\u5206\u652f\uff1agit push -f origin new-branch \u6ce8\u610f\u4e8b\u9879 \u5728\u4f7f\u7528 git [&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-21568","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21568","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=21568"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21568\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21568"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}