{"id":21563,"date":"2024-11-19T12:07:59","date_gmt":"2024-11-19T04:07:59","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21563\/"},"modified":"2024-11-19T12:07:59","modified_gmt":"2024-11-19T04:07:59","slug":"git-push%e4%ba%86%e6%80%8e%e4%b9%88%e6%92%a4%e9%94%80","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21563\/","title":{"rendered":"git push\u4e86\u600e\u4e48\u64a4\u9500"},"content":{"rendered":"<blockquote><p>\n  \u6709\u4e24\u79cd\u65b9\u6cd5\u53ef\u4ee5\u64a4\u9500 git push\uff1a\u521b\u5efa\u65b0\u63d0\u4ea4\u5e76\u5f3a\u5236\u63a8\u9001\uff1agit push &#8211;force origin main\u67e5\u770b reflog \u627e\u5230\u8981\u64a4\u9500\u7684 push \u64cd\u4f5c\uff0c\u7136\u540e\u91cd\u7f6e head \u5e76\u5f3a\u5236\u63a8\u9001\uff1agit reset sha-1-hash\uff1bgit push &#8211;force origin main\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/31\/2024053100063498885.jpg\" class=\"aligncenter\" title=\"git push\u4e86\u600e\u4e48\u64a4\u9500\u63d2\u56fe\" alt=\"git push\u4e86\u600e\u4e48\u64a4\u9500\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u64a4\u9500 Git Push<\/strong><\/p>\n<p>Git push \u547d\u4ee4\u7528\u4e8e\u5c06\u672c\u5730\u66f4\u6539\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\u3002\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u64a4\u9500 push \u64cd\u4f5c\u3002\u4ee5\u4e0b\u662f\u4e24\u79cd\u65b9\u6cd5\uff1a<\/p>\n<p><strong>\u65b9\u6cd5 1\uff1a\u5f3a\u5236\u63a8\u9001<\/strong><\/p>\n<ul>\n<li>\u9996\u5148\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u63d0\u4ea4\u6765\u6062\u590d\u60a8\u5e0c\u671b\u64a4\u9500\u7684\u66f4\u6539\u3002<\/li>\n<li>\u7136\u540e\uff0c\u4f7f\u7528 &#8211;force \u6807\u5fd7\u6267\u884c\u5f3a\u5236\u63a8\u9001\uff1a<\/li>\n<\/ul>\n<pre>git push --force origin main<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u8986\u76d6\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u7684\u66f4\u6539\uff0c\u5e76\u7528\u65b0\u7684\u63d0\u4ea4\u66ff\u6362\u5b83\u4eec\u3002<\/p>\n<p><strong>\u65b9\u6cd5 2\uff1a\u4f7f\u7528 Reflog<\/strong><\/p>\n<p>Git \u7ef4\u62a4\u4e86\u4e00\u4e2a\u540d\u4e3a Reflog \u7684\u5386\u53f2\u8bb0\u5f55\uff0c\u5176\u4e2d\u8bb0\u5f55\u4e86\u5bf9\u63d0\u4ea4\u548c\u5206\u652f\u7684\u66f4\u6539\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528  reflog \u547d\u4ee4\u67e5\u770b Reflog\uff1a<\/p>\n<pre>git reflog<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728 Reflog \u4e2d\u627e\u5230\u60a8\u5e0c\u671b\u64a4\u9500\u7684 push \u64cd\u4f5c\u7684 SHA-1 \u54c8\u5e0c\u3002\u7136\u540e\uff0c\u4f7f\u7528 git reset \u547d\u4ee4\u5c06 HEAD \u6062\u590d\u5230\u8be5\u54c8\u5e0c\uff1a<\/p>\n<pre>git reset SHA-1-HASH<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6700\u540e\uff0c\u5f3a\u5236\u63a8\u9001 HEAD \u5230\u8fdc\u7a0b\u4ed3\u5e93\uff1a<\/p>\n<pre>git push --force origin main<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f push\u4e86\u600e\u4e48\u64a4\u9500\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>\u6709\u4e24\u79cd\u65b9\u6cd5\u53ef\u4ee5\u64a4\u9500 git push\uff1a\u521b\u5efa\u65b0\u63d0\u4ea4\u5e76\u5f3a\u5236\u63a8\u9001\uff1agit push &#8211;force origin main\u67e5\u770b reflog \u627e\u5230\u8981\u64a4\u9500\u7684 push \u64cd\u4f5c\uff0c\u7136\u540e\u91cd\u7f6e head \u5e76\u5f3a\u5236\u63a8\u9001\uff1agit reset sha-1-hash\uff1bgit push &#8211;force origin main \u5982\u4f55\u64a4\u9500 Git Push Git push \u547d\u4ee4\u7528\u4e8e\u5c06\u672c\u5730\u66f4\u6539\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\u3002\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u64a4\u9500 push \u64cd\u4f5c\u3002\u4ee5\u4e0b\u662f\u4e24\u79cd\u65b9\u6cd5\uff1a \u65b9\u6cd5 1\uff1a\u5f3a\u5236\u63a8\u9001 \u9996\u5148\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u63d0\u4ea4\u6765\u6062\u590d\u60a8\u5e0c\u671b\u64a4\u9500\u7684\u66f4\u6539\u3002 \u7136\u540e\uff0c\u4f7f\u7528 &#8211;force \u6807\u5fd7\u6267\u884c\u5f3a\u5236\u63a8\u9001\uff1a git push &#8211;force origin main \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u5c06\u8986\u76d6\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u7684\u66f4\u6539\uff0c\u5e76\u7528\u65b0\u7684\u63d0\u4ea4\u66ff\u6362\u5b83\u4eec\u3002 \u65b9\u6cd5 2\uff1a\u4f7f\u7528 Reflog Git \u7ef4\u62a4\u4e86\u4e00\u4e2a\u540d\u4e3a Reflog \u7684\u5386\u53f2\u8bb0\u5f55\uff0c\u5176\u4e2d\u8bb0\u5f55\u4e86\u5bf9\u63d0\u4ea4\u548c\u5206\u652f\u7684\u66f4\u6539\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528 reflog \u547d\u4ee4\u67e5\u770b Reflog\uff1a git reflog \u767b\u5f55\u540e\u590d\u5236 \u5728 [&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-21563","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21563","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=21563"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21563\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21563"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21563"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}