{"id":19351,"date":"2024-11-19T16:17:27","date_gmt":"2024-11-19T08:17:27","guid":{"rendered":"https:\/\/fwq.ai\/blog\/19351\/"},"modified":"2024-11-19T16:17:27","modified_gmt":"2024-11-19T08:17:27","slug":"%e6%b7%b1%e5%85%a5%e4%ba%86%e8%a7%a3git-rebase%e7%9a%84%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/19351\/","title":{"rendered":"\u6df1\u5165\u4e86\u89e3git rebase\u7684\u4f7f\u7528\u65b9\u6cd5"},"content":{"rendered":"<p>git\u662f\u76ee\u524d\u6700\u6d41\u884c\u7684\u7248\u672c\u63a7\u5236\u5de5\u5177\u4e4b\u4e00\uff0c\u5b83\u5e26\u6765\u4e86\u4e00\u4e9b\u6539\u53d8\uff0c\u5305\u62ec\u652f\u6301\u591a\u4e2a\u5206\u652f\uff0c\u5e76\u4e14\u6709\u52a9\u4e8e\u7ba1\u7406\u4ee3\u7801\u7248\u672c\u66f4\u65b0\u3002\u5f53\u6211\u4eec\u5728\u56e2\u961f\u4e2d\u5408\u4f5c\u5f00\u53d1\u65f6\uff0c\u5f80\u5f80\u4f1a\u9047\u5230\u4e00\u4e9b\u65f6\u5019\u9700\u8981\u5408\u5e76\u5206\u652f\uff0c\u800c\u8fd9\u65f6git rebase\u7684\u4f7f\u7528\u5c31\u663e\u5f97\u6781\u4e3a\u91cd\u8981\u3002\u4e0b\u9762\u6211\u4eec\u6765\u4e00\u8d77\u4e86\u89e3\u4e00\u4e0bgit rebase\u7684\u7528\u6cd5\u3002<\/p>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u5148\u4e86\u89e3\u4e00\u4e0bGit\u5206\u652f\u5408\u5e76\u7684\u5de5\u4f5c\u65b9\u5f0f\u3002Git\u5206\u652f\u5408\u5e76\u6709\u4e24\u79cd\u65b9\u5f0f\uff1a\u4e00\u79cd\u662f\u5408\u5e76\u5206\u652f\uff0c\u5373\u4f7f\u7528 git merge \u547d\u4ee4\uff0c\u5b83\u5c06\u4e24\u4e2a\u5206\u652f\u7684\u4fee\u6539\u5408\u5e76\u5230\u4e00\u8d77\u3002\u53e6\u4e00\u79cd\u662f\u4f7f\u7528Git Rebase\u3002Git Rebase\u53ef\u4ee5\u5c06\u4e00\u4e2a\u5206\u652f\u7684\u4fee\u6539\u5e94\u7528\u5230\u53e6\u4e00\u4e2a\u5206\u652f\u4e0a\u3002\u8fd9\u79cd\u65b9\u5f0f\u6bd4\u5408\u5e76\u5206\u652f\u66f4\u52a0\u6e05\u6670\u3001\u7b80\u5355\uff0c\u540c\u65f6\u4f1a\u4ea7\u751f\u6574\u6d01\u7684 Git \u65e5\u5fd7\u3002<\/p>\n<p>Git Rebase\u7684\u4e3b\u8981\u4f5c\u7528\u662f\u91cd\u65b0\u6574\u5408\u63d0\u4ea4\uff0c\u5e76\u5c06\u5b83\u4eec\u653e\u5728\u4e00\u4e2a\u5e72\u51c0\u7684\u63d0\u4ea4\u8bb0\u5f55\u4e2d\u3002\u5b83\u53ef\u4ee5\u8ba9\u6211\u4eec\u7684\u63d0\u4ea4\u5386\u53f2\u4fdd\u6301\u6574\u6d01\uff0c\u8fd8\u80fd\u591f\u5e2e\u52a9\u6211\u4eec\u89e3\u51b3\u5408\u5e76\u51b2\u7a81\u7684\u95ee\u9898\u3002Git Rebase\u7684\u64cd\u4f5c\u8fc7\u7a0b\u6bd4Merge\u64cd\u4f5c\u66f4\u52a0\u590d\u6742\uff0c\u4f46\u662f\u4ecd\u7136\u662f\u4e00\u4e2a\u975e\u5e38\u6709\u7528\u7684\u5de5\u5177\u3002<\/p>\n<p>\u4e0b\u9762\u6211\u4eec\u901a\u8fc7\u4e00\u4e2a\u5b9e\u4f8b\u6765\u5b66\u4e60Git Rebase\u7684\u7528\u6cd5\u3002<\/p>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u5148\u521b\u5efa\u4e24\u4e2a\u5206\u652f\uff1amaster\u548cdev\u3002<\/p>\n<pre>git checkout -b master\ngit checkout -b dev<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728dev\u5206\u652f\u4e0a\uff0c\u6211\u4eec\u65b0\u5efa\u4e00\u4e2a\u6587\u4ef6\u5e76\u6dfb\u52a0\u5185\u5bb9\uff0c\u7136\u540e\u63d0\u4ea4\u3002<\/p>\n<pre>touch file.txt\necho \"This is a file.\" &gt;&gt; file.txt\ngit add .\ngit commit -m 'Added file.txt'<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5207\u6362\u56demaster\u5206\u652f\uff0c\u5e76\u4fee\u6539\u6587\u4ef6\u5185\u5bb9\u3002<\/p>\n<pre>git checkout master\necho \"This is a modified file.\" &gt; file.txt\ngit add .\ngit commit -m 'Modified file.txt'<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u73b0\u5728\u6211\u4eec\u8981\u5c06dev\u5206\u652f\u7684\u63d0\u4ea4\u5e94\u7528\u5230master\u5206\u652f\u4e0a\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 git rebase \u547d\u4ee4\u6765\u5b8c\u6210\u6b64\u64cd\u4f5c\u3002<\/p>\n<pre>git rebase dev<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6267\u884c\u4ee5\u4e0a\u547d\u4ee4\u540e\uff0cGit\u4f1a\u5c06dev\u5206\u652f\u4e0a\u7684\u63d0\u4ea4\u5e94\u7528\u5230master\u5206\u652f\u4e0a\uff0c\u5982\u679c\u51fa\u73b0\u5408\u5e76\u51b2\u7a81\uff0c\u6211\u4eec\u9700\u8981\u624b\u52a8\u89e3\u51b3\u5b83\u4eec\u3002<\/p>\n<p>Git Rebase\u7684\u6ce8\u610f\u4e8b\u9879\uff1a<\/p>\n<ol>\n<li>\u5b83\u4e0d\u5e94\u8be5\u5728\u516c\u5171\u5206\u652f\u4e0a\u6267\u884c\u3002<\/li>\n<li>\u6267\u884cGit Rebase\u64cd\u4f5c\u53ef\u80fd\u4f1a\u6539\u53d8\u63d0\u4ea4\u5386\u53f2\uff0c\u56e0\u6b64\u5e94\u8be5\u8c28\u614e\u4f7f\u7528\u5b83\u3002<\/li>\n<li>\u5982\u679c\u591a\u4e2a\u5f00\u53d1\u8005\u5728\u540c\u4e00\u5206\u652f\u4e0a\u5408\u4f5c\u5f00\u53d1\uff0c\u5219\u5e94\u8be5\u5728\u5408\u5e76\u4e4b\u524d\u5bf9\u5176\u8fdb\u884c\u534f\u8c03\u3002<\/li>\n<\/ol>\n<p>\u5728\u5408\u4f5c\u5f00\u53d1\u4e2d\uff0cGit Rebase\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u5de5\u5177\u3002\u5b83\u53ef\u4ee5\u8ba9\u6211\u4eec\u7684\u63d0\u4ea4\u5386\u53f2\u4fdd\u6301\u6574\u6d01\u3001\u6709\u5e8f\u3002\u6b64\u5916\uff0c\u5b83\u8fd8\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u89e3\u51b3\u5408\u5e76\u51b2\u7a81\u3002\u4e86\u89e3\u5e76\u6b63\u786e\u5730\u4f7f\u7528Git Rebase\u662f\u6bcf\u4e2a\u5f00\u53d1\u8005\u5fc5\u987b\u638c\u63e1\u7684\u6280\u80fd\u4e4b\u4e00\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6df1\u5165\u4e86\u89e3git rebase\u7684\u4f7f\u7528\u65b9\u6cd5\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>git\u662f\u76ee\u524d\u6700\u6d41\u884c\u7684\u7248\u672c\u63a7\u5236\u5de5\u5177\u4e4b\u4e00\uff0c\u5b83\u5e26\u6765\u4e86\u4e00\u4e9b\u6539\u53d8\uff0c\u5305\u62ec\u652f\u6301\u591a\u4e2a\u5206\u652f\uff0c\u5e76\u4e14\u6709\u52a9\u4e8e\u7ba1\u7406\u4ee3\u7801\u7248\u672c\u66f4\u65b0\u3002\u5f53\u6211\u4eec\u5728\u56e2\u961f\u4e2d\u5408\u4f5c\u5f00\u53d1\u65f6\uff0c\u5f80\u5f80\u4f1a\u9047\u5230\u4e00\u4e9b\u65f6\u5019\u9700\u8981\u5408\u5e76\u5206\u652f\uff0c\u800c\u8fd9\u65f6git rebase\u7684\u4f7f\u7528\u5c31\u663e\u5f97\u6781\u4e3a\u91cd\u8981\u3002\u4e0b\u9762\u6211\u4eec\u6765\u4e00\u8d77\u4e86\u89e3\u4e00\u4e0bgit rebase\u7684\u7528\u6cd5\u3002 \u9996\u5148\uff0c\u6211\u4eec\u5148\u4e86\u89e3\u4e00\u4e0bGit\u5206\u652f\u5408\u5e76\u7684\u5de5\u4f5c\u65b9\u5f0f\u3002Git\u5206\u652f\u5408\u5e76\u6709\u4e24\u79cd\u65b9\u5f0f\uff1a\u4e00\u79cd\u662f\u5408\u5e76\u5206\u652f\uff0c\u5373\u4f7f\u7528 git merge \u547d\u4ee4\uff0c\u5b83\u5c06\u4e24\u4e2a\u5206\u652f\u7684\u4fee\u6539\u5408\u5e76\u5230\u4e00\u8d77\u3002\u53e6\u4e00\u79cd\u662f\u4f7f\u7528Git Rebase\u3002Git Rebase\u53ef\u4ee5\u5c06\u4e00\u4e2a\u5206\u652f\u7684\u4fee\u6539\u5e94\u7528\u5230\u53e6\u4e00\u4e2a\u5206\u652f\u4e0a\u3002\u8fd9\u79cd\u65b9\u5f0f\u6bd4\u5408\u5e76\u5206\u652f\u66f4\u52a0\u6e05\u6670\u3001\u7b80\u5355\uff0c\u540c\u65f6\u4f1a\u4ea7\u751f\u6574\u6d01\u7684 Git \u65e5\u5fd7\u3002 Git Rebase\u7684\u4e3b\u8981\u4f5c\u7528\u662f\u91cd\u65b0\u6574\u5408\u63d0\u4ea4\uff0c\u5e76\u5c06\u5b83\u4eec\u653e\u5728\u4e00\u4e2a\u5e72\u51c0\u7684\u63d0\u4ea4\u8bb0\u5f55\u4e2d\u3002\u5b83\u53ef\u4ee5\u8ba9\u6211\u4eec\u7684\u63d0\u4ea4\u5386\u53f2\u4fdd\u6301\u6574\u6d01\uff0c\u8fd8\u80fd\u591f\u5e2e\u52a9\u6211\u4eec\u89e3\u51b3\u5408\u5e76\u51b2\u7a81\u7684\u95ee\u9898\u3002Git Rebase\u7684\u64cd\u4f5c\u8fc7\u7a0b\u6bd4Merge\u64cd\u4f5c\u66f4\u52a0\u590d\u6742\uff0c\u4f46\u662f\u4ecd\u7136\u662f\u4e00\u4e2a\u975e\u5e38\u6709\u7528\u7684\u5de5\u5177\u3002 \u4e0b\u9762\u6211\u4eec\u901a\u8fc7\u4e00\u4e2a\u5b9e\u4f8b\u6765\u5b66\u4e60Git Rebase\u7684\u7528\u6cd5\u3002 \u9996\u5148\uff0c\u6211\u4eec\u5148\u521b\u5efa\u4e24\u4e2a\u5206\u652f\uff1amaster\u548cdev\u3002 git checkout -b master git checkout -b dev \u767b\u5f55\u540e\u590d\u5236 \u5728dev\u5206\u652f\u4e0a\uff0c\u6211\u4eec\u65b0\u5efa\u4e00\u4e2a\u6587\u4ef6\u5e76\u6dfb\u52a0\u5185\u5bb9\uff0c\u7136\u540e\u63d0\u4ea4\u3002 touch file.txt echo &#8220;This is a file.&#8221; &gt;&gt; file.txt git add . git commit -m &#8216;Added file.txt&#8217; \u767b\u5f55\u540e\u590d\u5236 \u5207\u6362\u56demaster\u5206\u652f\uff0c\u5e76\u4fee\u6539\u6587\u4ef6\u5185\u5bb9\u3002 git checkout master echo &#8220;This is a modified file.&#8221; [&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-19351","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/19351","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=19351"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/19351\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=19351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=19351"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=19351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}