{"id":21567,"date":"2024-11-19T10:00:04","date_gmt":"2024-11-19T02:00:04","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21567\/"},"modified":"2024-11-19T10:00:04","modified_gmt":"2024-11-19T02:00:04","slug":"git%e6%8f%90%e4%ba%a4%e5%88%b0%e6%9c%ac%e5%9c%b0%e6%80%8e%e4%b9%88%e6%92%a4%e5%9b%9e","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21567\/","title":{"rendered":"git\u63d0\u4ea4\u5230\u672c\u5730\u600e\u4e48\u64a4\u56de"},"content":{"rendered":"<blockquote><p>\n  \u5982\u4f55\u64a4\u56de\u672c\u5730 git \u63d0\u4ea4\uff1f\u4f7f\u7528 git reset \u547d\u4ee4\uff0c\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a1. \u4f7f\u7528 git log \u67e5\u770b\u63d0\u4ea4\u5386\u53f2\uff1b2. \u8fd0\u884c git reset &#8211;soft \u547d\u4ee4\u5c06 head \u6307\u9488\u79fb\u52a8\u5230\u6307\u5b9a\u63d0\u4ea4\uff1b3. \u4f7f\u7528 git add \u6682\u5b58\u66f4\u6539\uff1b4. \u4f7f\u7528 git commit &#8211;amend \u63d0\u4ea4\u66f4\u6539\uff0c\u521b\u5efa\u65b0\u63d0\u4ea4\u5305\u542b\u64a4\u56de\u7684\u66f4\u6539\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/31\/2024053100095229649.jpg\" class=\"aligncenter\" title=\"git\u63d0\u4ea4\u5230\u672c\u5730\u600e\u4e48\u64a4\u56de\u63d2\u56fe\" alt=\"git\u63d0\u4ea4\u5230\u672c\u5730\u600e\u4e48\u64a4\u56de\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u64a4\u56de\u672c\u5730 Git \u63d0\u4ea4<\/strong><\/p>\n<p><strong>\u5feb\u901f\u56de\u7b54\uff1a<\/strong><\/p>\n<p>\u8981\u64a4\u56de\u672c\u5730 Git \u63d0\u4ea4\uff0c\u53ef\u4ee5\u4f7f\u7528  reset \u547d\u4ee4\u3002<\/p>\n<p><strong>\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li> <strong>\u68c0\u67e5\u63d0\u4ea4\u5386\u53f2\uff1a<\/strong>\u4f7f\u7528 git log \u547d\u4ee4\u67e5\u770b\u63d0\u4ea4\u5386\u53f2\uff0c\u627e\u5230\u8981\u64a4\u56de\u7684\u63d0\u4ea4\u3002<\/li>\n<li> <strong>\u4f7f\u7528 git reset \u547d\u4ee4\uff1a<\/strong>\u8fd0\u884c git reset &#8211;soft \u547d\u4ee4\u3002\u8fd9\u4f1a\u5c06 HEAD \u6307\u9488\u79fb\u52a8\u5230\u6307\u5b9a\u7684\u63d0\u4ea4\uff0c\u4f46\u4e0d\u4f1a\u6539\u53d8\u5de5\u4f5c\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\u3002<\/li>\n<li> <strong>\u6682\u5b58\u66f4\u6539\uff1a<\/strong>\u4f7f\u7528 git add \u547d\u4ee4\u6682\u5b58\u8981\u64a4\u56de\u7684\u66f4\u6539\u3002<\/li>\n<li> <strong>\u63d0\u4ea4\u66f4\u6539\uff1a<\/strong>\u4f7f\u7528 git commit &#8211;amend \u547d\u4ee4\u63d0\u4ea4\u66f4\u6539\u3002\u8fd9\u4f1a\u521b\u5efa\u65b0\u63d0\u4ea4\uff0c\u5176\u4e2d\u5305\u542b\u64a4\u56de\u7684\u66f4\u6539\u3002<\/li>\n<\/ol>\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n<ul>\n<li>&#8211;soft \u9009\u9879\u53ea\u79fb\u52a8 HEAD \u6307\u9488\uff0c\u4e0d\u4f1a\u4fee\u6539\u6587\u4ef6\u3002\u82e5\u8981\u4fee\u6539\u6587\u4ef6\uff0c\u8bf7\u4f7f\u7528 &#8211;mixed \u6216 &#8211;hard \u9009\u9879\uff0c\u4f46\u5efa\u8bae\u8c28\u614e\u4f7f\u7528\u3002<\/li>\n<li>\u5982\u679c\u9700\u8981\u64a4\u56de\u591a\u4e2a\u63d0\u4ea4\uff0c\u53ef\u4ee5\u4f7f\u7528 &#8211;patch \u9009\u9879\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u63d0\u4ea4\u5230\u672c\u5730\u600e\u4e48\u64a4\u56de\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>\u5982\u4f55\u64a4\u56de\u672c\u5730 git \u63d0\u4ea4\uff1f\u4f7f\u7528 git reset \u547d\u4ee4\uff0c\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a1. \u4f7f\u7528 git log \u67e5\u770b\u63d0\u4ea4\u5386\u53f2\uff1b2. \u8fd0\u884c git reset &#8211;soft \u547d\u4ee4\u5c06 head \u6307\u9488\u79fb\u52a8\u5230\u6307\u5b9a\u63d0\u4ea4\uff1b3. \u4f7f\u7528 git add \u6682\u5b58\u66f4\u6539\uff1b4. \u4f7f\u7528 git commit &#8211;amend \u63d0\u4ea4\u66f4\u6539\uff0c\u521b\u5efa\u65b0\u63d0\u4ea4\u5305\u542b\u64a4\u56de\u7684\u66f4\u6539\u3002 \u5982\u4f55\u64a4\u56de\u672c\u5730 Git \u63d0\u4ea4 \u5feb\u901f\u56de\u7b54\uff1a \u8981\u64a4\u56de\u672c\u5730 Git \u63d0\u4ea4\uff0c\u53ef\u4ee5\u4f7f\u7528 reset \u547d\u4ee4\u3002 \u8be6\u7ec6\u6b65\u9aa4\uff1a \u68c0\u67e5\u63d0\u4ea4\u5386\u53f2\uff1a\u4f7f\u7528 git log \u547d\u4ee4\u67e5\u770b\u63d0\u4ea4\u5386\u53f2\uff0c\u627e\u5230\u8981\u64a4\u56de\u7684\u63d0\u4ea4\u3002 \u4f7f\u7528 git reset \u547d\u4ee4\uff1a\u8fd0\u884c git reset &#8211;soft \u547d\u4ee4\u3002\u8fd9\u4f1a\u5c06 HEAD \u6307\u9488\u79fb\u52a8\u5230\u6307\u5b9a\u7684\u63d0\u4ea4\uff0c\u4f46\u4e0d\u4f1a\u6539\u53d8\u5de5\u4f5c\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\u3002 \u6682\u5b58\u66f4\u6539\uff1a\u4f7f\u7528 git add \u547d\u4ee4\u6682\u5b58\u8981\u64a4\u56de\u7684\u66f4\u6539\u3002 \u63d0\u4ea4\u66f4\u6539\uff1a\u4f7f\u7528 [&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-21567","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21567","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=21567"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21567\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21567"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21567"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21567"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}