{"id":1636,"date":"2024-12-05T22:01:12","date_gmt":"2024-12-05T14:01:12","guid":{"rendered":"https:\/\/thereisno.top\/?p=1636"},"modified":"2024-12-07T21:28:23","modified_gmt":"2024-12-07T13:28:23","slug":"%e5%b0%86%e5%a4%9a%e4%b8%aacommit-rebase%e5%90%88%e5%b9%b6%e4%b8%ba%e4%b8%80%e4%b8%aa%e6%8f%90%e4%ba%a4","status":"publish","type":"post","link":"https:\/\/thereisno.top\/?p=1636","title":{"rendered":"\u5c06\u591a\u4e2acommit\u00a0rebase\u5408\u5e76\u4e3a\u4e00\u4e2a\u63d0\u4ea4"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">1&nbsp;\u67e5\u770b\u65e5\u5fd7<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u67e5\u770b\u9700\u8981\u6c47\u603b\u51e0\u4e2acommit\u7684\uff0c\u8bb0\u4e0b\u6700\u65e7\u7684id\u6216\u8005\u5012\u6570\u7b2c\u51e0\u4e2a\uff0c\u7136\u540e\u9009\u62e9reset&nbsp;\u6216\u8005rebase\u65b9\u6cd5<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f8b\u5982\u4e0b\u9762\u67095\u4e2a\u63d0\u4ea4\uff0c\u60f3\u8981\u628a\u4ece3\u52305\u7684\u63d0\u4ea4\u6c47\u603b\u5728\u4e00\u8d77\u4f5c\u4e3a\u4e00\u6b21\u63d0\u4ea4\uff0c\u5f97\u5230&nbsp;1 2 6{3 4 5\u7684\u6c47\u603b}<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git reflog\n05a3854 (HEAD -&gt; main) HEAD@{4}: commit: 5\ne125d52 HEAD@{5}: commit: 4\nec70c06 HEAD@{6}: commit: 3\n<mark style=\"background-color:#fcb900\" class=\"has-inline-color\">a4621de<\/mark> HEAD@{7}: commit: 2\n065dc62 HEAD@{8}: commit (initial): 1\n<\/code><\/pre>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">2 git rebase -i HEAD~n&nbsp;&nbsp;\u6216\u8005&nbsp;git rebase -i commitid<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Commitid \u4e3a\u9009\u5b9a\u7684\u63d0\u4ea4\uff0c\u540e\u7eed\u7684\u63d0\u4ea4\u5408\u5e76\u5230\u6b64\u57fa\u7840\u4e0a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git rebase -i <mark style=\"background-color:#fcb900\" class=\"has-inline-color\">a4621de<\/mark>\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6b64\u65f6\u8fdb\u5165vi\u7f16\u8f91\uff0c\u5c06\u540e\u524d\u4e2acommit\u7684pick\u4fee\u6539\u4e3adrop\uff0c\u4fdd\u7559\u6700\u540e\u4e00\u4e2apick\u3002:wq\u4fdd\u5b58\u9000\u51fa<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"581\" height=\"510\" src=\"https:\/\/thereisno.top\/wp-content\/uploads\/2024\/12\/image-1.png\" alt=\"\" class=\"wp-image-1637\" srcset=\"https:\/\/thereisno.top\/wp-content\/uploads\/2024\/12\/image-1.png 581w, https:\/\/thereisno.top\/wp-content\/uploads\/2024\/12\/image-1-300x263.png 300w\" sizes=\"auto, (max-width: 581px) 100vw, 581px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>pick\uff1a\u4f7f\u7528commit\u3002\nreword\uff1a\u4f7f\u7528commit\uff0c\u4fee\u6539commit\u4fe1\u606f\u3002\nsquash\uff1a\u4f7f\u7528commit\uff0c\u5c06commit\u4fe1\u606f\u5408\u5165\u4e0a\u4e00\u4e2acommit\u3002\ndrop\uff1a\u4e22\u5f03commit\u4fe1\u606f\u3002\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\u6267\u884c\u7ed3\u679c\uff1a\ngit rebase -i a4621de\nAuto-merging aaa.txt\nCONFLICT (content): Merge conflict in aaa.txt\nerror: could not apply 05a3854... 5\nhint: Resolve all conflicts manually, mark them as resolved with\nhint: \"git add\/rm &lt;conflicted_files&gt;\", then run \"git rebase --continue\".\nhint: You can instead skip this commit: run \"git rebase --skip\".\nhint: To abort and get back to the state before \"git rebase\", run \"git rebase --abort\".\nCould not apply 05a3854... 5\n% git status\ninteractive rebase in progress; onto a4621de\nLast commands done (3 commands done):\n   drop e125d52 4\n   pick 05a3854 5\n  (see more in file .git\/rebase-merge\/done)\nNo commands remaining.\n<mark style=\"background-color:#fcb900\" class=\"has-inline-color\">You are currently rebasing branch 'main' on 'a4621de<\/mark>'.\n  (fix conflicts and then run \"git rebase --continue\")\n  (use \"git rebase --skip\" to skip this patch)\n  (use \"git rebase --abort\" to check out the original branch)\n\nUnmerged paths:\n  (use \"git restore --staged &lt;file&gt;...\" to unstage)\n  (use \"git add &lt;file&gt;...\" to mark resolution)\n\tboth modified:   aaa.txt\n\n<mark style=\"background-color:#fcb900\" class=\"has-inline-color\">\u89e3\u51b3\u51b2\u7a81<\/mark>\n% vi aaa.txt \n% git add .\n% git commit -m \"rebase\"\n&#91;detached HEAD 9d52fd9] rebase\n 1 file changed, 3 insertions(+), 1 deletion(-)\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">\u6267\u884crebase\u65f6\uff0c\u5728\u9009\u5b9a\u7684\u63d0\u4ea4\u4e0a\u521b\u5efa\u5e76\u5207\u6362\u5230\u4e34\u65f6\u5206\u652f<\/mark>\uff0c\u7136\u540e\u5c06\u6700\u65b0\u7684\u591a\u4e2a\u63d0\u4ea4merge\u5230\u4e34\u65f6\u5206\u652f\uff0cmerge\u4f1a\u4ea7\u751f\u51b2\u7a81\uff0c\u89e3\u51b3\u51b2\u7a81\u540e\u4f5c\u4e3a\u4e00\u6b21\u63d0\u4ea4\u8fdb\u884c\u63d0\u4ea4\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3\u3001\u64cd\u4f5c\u5b8c\u4e4b\u540e\uff0c\u4e2d\u95f4\u63d0\u4ea4\u65e5\u5fd7\u6ca1\u6709\u4e86<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>git log\ncommit 9d52fd9b0da0bed7fecd13944a81541913330a52 (HEAD)\nDate:   Thu Dec 5 20:36:34 2024 +0800\n\n    rebase\n\ncommit a4621dec940e28d3b498c0f04f6b580a84d1ba3c\nDate:   Thu Dec 5 20:16:25 2024 +0800\n\n    2\n\ncommit 065dc62c96d5a2b0cfc042985db5603e2f006c1e\nDate:   Thu Dec 5 20:15:56 2024 +0800\n\n    1\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">4\u3001\u6ce8\u610f\uff1a\u6b64\u65f6rebase\u5e76\u672a\u7ed3\u675f<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6b64\u65f6\u8fd8\u5728\u4e34\u65f6\u5206\u652f\u4e0a\uff0c<mark style=\"background-color:#fcb900\" class=\"has-inline-color\">\u6267\u884cgit rebase &#8211;continue<\/mark>&nbsp;\u4f1a\u81ea\u52a8\u56de\u5230\u64cd\u4f5c\u524d\u7684\u5206\u652f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>% git status\ninteractive rebase in progress; onto a4621de\nLast commands done (3 commands done):\n   drop e125d52 4\n   pick 05a3854 5\n  (see more in file .git\/rebase-merge\/done)\nNo commands remaining.\nYou are currently editing a commit while rebasing branch 'main' on 'a4621de'.\n  (use \"git commit --amend\" to amend the current commit)\n  (use \"<mark style=\"background-color:#fcb900\" class=\"has-inline-color\">git rebase --continue<\/mark>\" once you are satisfied with your changes)\n\nnothing to commit, working tree clean\n% git rebase --continue\nSuccessfully rebased and updated refs\/heads\/main.\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/activity.huaweicloud.com\/cps.html?fromacct=6d7bf5b928b847b3a50bbf7d7c439354&amp;utm_source=V1g3MDY4NTY=&amp;utm_medium=cps&amp;utm_campaign=201905\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"310\" src=\"https:\/\/thereisno.top\/wp-content\/uploads\/2024\/12\/hwFlex-1024x310.jpeg\" alt=\"\" class=\"wp-image-2428\" srcset=\"https:\/\/thereisno.top\/wp-content\/uploads\/2024\/12\/hwFlex-1024x310.jpeg 1024w, https:\/\/thereisno.top\/wp-content\/uploads\/2024\/12\/hwFlex-300x91.jpeg 300w, https:\/\/thereisno.top\/wp-content\/uploads\/2024\/12\/hwFlex-768x233.jpeg 768w, https:\/\/thereisno.top\/wp-content\/uploads\/2024\/12\/hwFlex.jpeg 1320w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><figcaption class=\"wp-element-caption\">Flexus L\u5b9e\u4f8b 2\u68382G2M \u7279\u4ef738\u51431\u5e74<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">5 git push &#8211;force <\/h2>\n","protected":false},"excerpt":{"rendered":"<p>1&nbsp;\u67e5\u770b\u65e5\u5fd7 \u67e5\u770b\u9700\u8981\u6c47\u603b\u51e0\u4e2acommit\u7684\uff0c\u8bb0\u4e0b\u6700\u65e7\u7684id\u6216\u8005\u5012\u6570\u7b2c\u51e0\u4e2a\uff0c\u7136\u540e\u9009\u62e9reset&#038;nb &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/thereisno.top\/?p=1636\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c\u5c06\u591a\u4e2acommit\u00a0rebase\u5408\u5e76\u4e3a\u4e00\u4e2a\u63d0\u4ea4\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[2,180],"class_list":["post-1636","post","type-post","status-publish","format-standard","hentry","category-git","tag-git","tag-rebase"],"_links":{"self":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts\/1636","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1636"}],"version-history":[{"count":3,"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts\/1636\/revisions"}],"predecessor-version":[{"id":1667,"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts\/1636\/revisions\/1667"}],"wp:attachment":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1636"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1636"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1636"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}