{"id":92768,"date":"2026-08-11T08:57:23","date_gmt":"2026-08-11T00:57:23","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/92768.html"},"modified":"2026-08-11T08:57:23","modified_gmt":"2026-08-11T00:57:23","slug":"16-%e6%94%b9%e5%86%99%e5%8e%86%e5%8f%b2-rebase%ef%bc%9a%e6%90%ac%e5%ae%b6%e5%88%b0%e6%96%b0%e6%a5%bc%e5%b1%82%ef%bc%8c%e4%b8%8d%e6%98%af%e5%90%88%e5%b9%b6","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/92768.html","title":{"rendered":"16 \u2014 \u6539\u5199\u5386\u53f2 rebase\uff1a\u642c\u5bb6\u5230\u65b0\u697c\u5c42\uff0c\u4e0d\u662f\u5408\u5e76"},"content":{"rendered":"<h3>\u5199\u5728\u524d\u9762&#xff1a;\u8fd9\u4e00\u7ae0\u8981\u89e3\u51b3\u4ec0\u4e48<\/h3>\n<p>\u5982\u679c\u4f60\u5df2\u7ecf\u4f1a\u4e86\u5206\u652f\u548c\u5408\u5e76&#xff0c;\u5fc3\u91cc\u53ef\u80fd\u8fd8\u6709\u4e00\u4e2a\u66f4\u5177\u4f53\u7684\u56f0\u60d1&#xff1a;\u6bcf\u6b21 merge \u90fd\u4f1a\u591a\u51fa\u4e00\u4e2a\u5408\u5e76\u63d0\u4ea4&#xff0c;\u5206\u652f\u7ebf\u7f20\u6210\u4e00\u56e2\u3002 \u6709\u6ca1\u6709\u529e\u6cd5\u628a\u4ee3\u7801\u6539\u52a8\u300c\u7406\u6210\u4e00\u6761\u76f4\u7ebf\u300d&#xff1f;<\/p>\n<p>\u5b66\u5b8c\u540e&#xff0c;\u4f60\u5e94\u8be5\u80fd&#xff1a;<\/p>\n<li>\u8bf4\u6e05\u695a rebase \u548c merge \u7684\u533a\u522b&#xff08;\u7528\u300c\u642c\u5bb6\u300d\u7684\u6bd4\u55bb&#xff09;<\/li>\n<li>\u7528 git rebase \u628a\u5206\u652f\u7ebf\u6574\u7406\u6210\u76f4\u7ebf<\/li>\n<li>\u7528 git rebase -i \u538b\u7f29\u3001\u6539\u5199\u3001\u91cd\u6392\u63d0\u4ea4\u8bb0\u5f55<\/li>\n<li>\u9047\u5230 rebase \u51b2\u7a81\u65f6\u51b7\u9759\u89e3\u51b3<\/li>\n<li>\u7262\u8bb0\u300c\u5df2\u63a8\u9001\u7684\u63d0\u4ea4\u7edd\u5bf9\u4e0d rebase\u300d\u8fd9\u6761\u94c1\u5f8b<\/li>\n<p>\u8bfb\u8005\u8bbe\u5b9a&#xff1a; \u5927\u4e00\u540c\u5b66&#xff0c;\u5df2\u7ecf\u5b66\u8fc7\u5206\u652f\u548c\u5408\u5e76&#xff0c;\u77e5\u9053 commit\u3001branch\u3001merge \u662f\u4ec0\u4e48&#xff0c;\u4f46\u770b\u5230\u5206\u53c9\u7684\u5386\u53f2\u7ebf\u4f1a\u5934\u75bc\u3002<\/p>\n<hr \/>\n<h3>1. \u5b9a\u4f4d&#xff1a;\u4e3a\u4ec0\u4e48\u8981\u8bb2 rebase<\/h3>\n<h4>1.1 \u4e00\u53e5\u8bdd\u5148\u8bb0\u4f4f<\/h4>\n<p>rebase &#061; \u628a\u4f60\u7684\u6539\u52a8\u642c\u5bb6\u5230\u522b\u4eba\u6700\u65b0\u4ee3\u7801\u7684\u4e0a\u9762&#xff0c;\u8ba9\u5386\u53f2\u53d8\u6210\u4e00\u6761\u76f4\u7ebf\u3002<\/p>\n<p>\u4e0d\u662f\u628a\u4e24\u4efd\u4ee3\u7801\u300c\u548c\u7a00\u6ce5\u300d\u6df7\u5728\u4e00\u8d77&#xff08;\u90a3\u662f merge&#xff09;&#xff0c;\u800c\u662f\u628a\u4f60\u7684\u63d0\u4ea4\u4e00\u4e2a\u4e00\u4e2a\u300c\u642c\u5230\u300d\u65b0\u57fa\u7ebf\u7684\u697c\u4e0a\u3002<\/p>\n<h4>1.2 \u6ca1\u6709 rebase \u4f1a\u600e\u6837&#xff08;\u75db\u70b9\u573a\u666f\u8868&#xff09;<\/h4>\n<table>\n<tr>\u573a\u666f\u6ca1\u6709 rebase \u7684\u75db\u6709\u4e86 rebase \u4e4b\u540e<\/tr>\n<tbody>\n<tr>\n<td>\u529f\u80fd\u5206\u652f\u5f00\u53d1\u4e09\u5929&#xff0c;\u4e3b\u5206\u652f\u5df2\u66f4\u65b0<\/td>\n<td>merge \u4ea7\u751f\u5408\u5e76\u63d0\u4ea4&#xff0c;\u5386\u53f2\u7ebf\u5206\u53c9\u53c8\u6c47\u5408<\/td>\n<td>rebase \u8ba9\u4f60\u7684\u63d0\u4ea4\u53d8\u6210\u4e00\u6761\u76f4\u7ebf<\/td>\n<\/tr>\n<tr>\n<td>\u63d0\u4ea4\u4e86 5 \u6b21\u5c0f\u4fee\u6539&#xff0c;\u5168\u662f\u300c\u4fee typo\u300d<\/td>\n<td>\u5386\u53f2\u5168\u662f\u300c\u4fee typo\u300d\u300c\u53c8\u4fee typo\u300d&#xff0c;\u4e22\u4eba<\/td>\n<td>\u4ea4\u4e92\u5f0f rebase \u628a 5 \u4e2a squash \u6210 1 \u4e2a<\/td>\n<\/tr>\n<tr>\n<td>\u60f3\u8c03\u6574\u63d0\u4ea4\u987a\u5e8f<\/td>\n<td>\u53ea\u80fd\u5220\u4e86\u91cd\u6765<\/td>\n<td>git rebase -i \u62d6\u4e00\u62d6\u987a\u5e8f\u5c31\u884c<\/td>\n<\/tr>\n<tr>\n<td>\u5199\u9519\u63d0\u4ea4\u4fe1\u606f<\/td>\n<td>\u6539\u4e0d\u4e86<\/td>\n<td>git rebase -i \u9009 reword&#xff0c;\u53ea\u6539\u6587\u5b57<\/td>\n<\/tr>\n<tr>\n<td>\u4ee3\u7801\u5ba1\u67e5\u65f6\u5386\u53f2\u592a\u4e71<\/td>\n<td>\u5ba1\u67e5\u7684\u4eba\u770b\u5f97\u773c\u82b1<\/td>\n<td>rebase \u4e4b\u540e\u4e00\u6761\u7ebf&#xff0c;\u5ba1\u67e5\u66f4\u8f7b\u677e<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>1.3 \u548c\u4f60\u5df2\u7ecf\u4f1a\u7684\u4e8b\u5bf9\u6bd4<\/h4>\n<p>\u4f60\u5df2\u7ecf\u4f1a\u4e86 git merge&#xff1a;\u628a\u4e24\u4e2a\u5206\u652f\u7684\u4ee3\u7801\u5408\u5230\u4e00\u8d77&#xff0c;\u4f1a\u4ea7\u751f\u4e00\u4e2a\u5408\u5e76\u63d0\u4ea4&#xff0c;\u5386\u53f2\u4f1a\u5206\u53c9\u518d\u6c47\u5408\u3002<\/p>\n<table>\n<tr>\u5bf9\u6bd4\u9879merge&#xff08;\u4f60\u5df2\u7ecf\u4f1a\u7684&#xff09;rebase&#xff08;\u8fd9\u4e00\u7ae0\u8981\u5b66\u7684&#xff09;<\/tr>\n<tbody>\n<tr>\n<td>\u5386\u53f2\u7ebf\u5f62\u72b6<\/td>\n<td>\u5206\u53c9 &#043; \u6c47\u5408&#xff0c;\u6709\u5408\u5e76\u63d0\u4ea4<\/td>\n<td>\u4e00\u6761\u76f4\u7ebf&#xff0c;\u6ca1\u6709\u5408\u5e76\u63d0\u4ea4<\/td>\n<\/tr>\n<tr>\n<td>\u672c\u8d28<\/td>\n<td>\u4e24\u4e2a\u5206\u652f\u300c\u548c\u7a00\u6ce5\u300d<\/td>\n<td>\u4f60\u7684\u63d0\u4ea4\u300c\u642c\u5bb6\u300d\u5230\u65b0\u57fa\u7ebf\u4e0a\u9762<\/td>\n<\/tr>\n<tr>\n<td>\u7ed3\u679c\u4ee3\u7801<\/td>\n<td>\u4e00\u6837<\/td>\n<td>\u4e00\u6837<\/td>\n<\/tr>\n<tr>\n<td>\u5b89\u5168\u6027<\/td>\n<td>\u5bf9\u5df2\u63a8\u9001\u5206\u652f\u5b89\u5168<\/td>\n<td>\u5bf9\u5df2\u63a8\u9001\u5206\u652f\u5371\u9669<\/td>\n<\/tr>\n<tr>\n<td>\u9002\u7528\u573a\u666f<\/td>\n<td>\u5408\u5e76\u516c\u5171\u5206\u652f<\/td>\n<td>\u6574\u7406\u81ea\u5df1\u7684\u529f\u80fd\u5206\u652f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5c0f\u63d0\u793a&#xff1a;\u6700\u7ec8\u4ee3\u7801\u5185\u5bb9\u662f\u4e00\u6837\u7684&#xff0c;\u53ea\u662f\u5386\u53f2\u7684\u4e66\u5199\u65b9\u5f0f\u4e0d\u540c\u3002merge \u4fdd\u7559\u4e86\u300c\u5206\u53c9\u8fc7\u300d\u8fd9\u4e2a\u4e8b\u5b9e&#xff0c;rebase \u6539\u5199\u4e86\u5386\u53f2\u8ba9\u4f60\u5047\u88c5\u300c\u4e00\u5207\u90fd\u662f\u5728\u6700\u65b0\u4ee3\u7801\u4e0a\u987a\u6ed1\u5f00\u53d1\u7684\u300d\u3002<\/p>\n<hr \/>\n<h3>2. \u672c\u8d28&#xff1a;rebase \u5230\u5e95\u662f\u4ec0\u4e48&#xff08;\u767d\u8bdd &#043; \u6bd4\u55bb &#043; \u56fe\u89e3&#xff09;<\/h3>\n<h4>2.1 \u642c\u5bb6\u5230\u65b0\u697c\u5c42<\/h4>\n<ul>\n<li>\u4e3b\u5206\u652f main \u662f\u4e00\u697c&#xff0c;\u6700\u8fd1\u6709\u4eba\u7ffb\u4fee\u4e86&#xff0c;\u5730\u9762\u6362\u6210\u4e86\u65b0\u5730\u677f\u3002<\/li>\n<li>\u4f60\u7684\u529f\u80fd\u5206\u652f \u662f\u4e8c\u697c&#xff0c;\u4f60\u5728\u65e7\u5730\u677f\u4e0a\u88c5\u4fee\u4e86\u81ea\u5df1\u7684\u623f\u95f4\u3002<\/li>\n<\/ul>\n<p>\u73b0\u5728\u4f60\u60f3\u8ba9\u4f60\u7684\u623f\u95f4\u5efa\u5728\u65b0\u5730\u677f\u4e0a\u9762\u3002\u600e\u4e48\u529e&#xff1f;<\/p>\n<ul>\n<li>merge&#xff1a;\u5728\u4e00\u697c\u548c\u4e8c\u697c\u4e4b\u95f4\u642d\u4e00\u4e2a\u7a7a\u4e2d\u8d70\u5eca&#xff0c;\u4e24\u4e2a\u697c\u5c42\u90fd\u4fdd\u7559&#xff0c;\u8d70\u5eca\u5c31\u662f\u5408\u5e76\u63d0\u4ea4\u3002<\/li>\n<li>rebase&#xff1a;\u628a\u4f60\u7684\u6574\u4e2a\u623f\u95f4\u642c\u5230\u65b0\u5730\u677f\u4e0a\u9762\u3002\u4f60\u7684\u623f\u95f4\u4e0d\u53d8&#xff0c;\u4f46\u4e0b\u9762\u7684\u5730\u57fa\u53d8\u6210\u4e86\u6700\u65b0\u7684\u3002<\/li>\n<\/ul>\n<p>\u7528 Git \u7684\u8bdd\u8bf4&#xff1a;<\/p>\n<li>\u627e\u5230\u4e24\u4e2a\u5206\u652f\u7684\u5206\u53c9\u70b9&#xff08;\u5171\u540c\u7956\u5148&#xff09;<\/li>\n<li>\u628a\u4f60\u7684\u5206\u652f\u4e0a\u6bcf\u4e2a\u63d0\u4ea4\u7684\u6539\u52a8\u300c\u8bb0\u5fc6\u300d\u4e0b\u6765<\/li>\n<li>\u5148\u628a\u4f60\u7684\u5206\u652f\u6307\u9488\u79fb\u5230\u76ee\u6807\u5206\u652f\u7684\u6700\u65b0\u4f4d\u7f6e&#xff08;\u65b0\u57fa\u7ebf&#xff09;<\/li>\n<li>\u628a\u8bb0\u5fc6\u4e0b\u6765\u7684\u6539\u52a8\u4e00\u4e2a\u4e00\u4e2a\u91cd\u65b0\u5e94\u7528\u4e0a\u53bb<\/li>\n<li>\u6bcf\u91cd\u65b0\u5e94\u7528\u4e00\u6b21&#xff0c;\u5c31\u4ea7\u751f\u4e00\u4e2a\u65b0\u7684\u63d0\u4ea4&#xff08;\u54c8\u5e0c\u503c\u4e0d\u540c&#xff09;<\/li>\n<h4>2.2 \u770b\u56fe\u8bf4\u8bdd<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260811005721-6a7a7371b3922.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u56fe&#xff1a;merge \u4fdd\u7559\u5206\u53c9&#xff0c;rebase \u53d8\u6210\u76f4\u7ebf\u3002<\/p>\n<p>merge \u4e4b\u540e\u7684\u5386\u53f2&#xff1a;<\/p>\n<p>*   5a3b1c2 Merge branch &#039;feature&#039;<br \/>\n|\\\\<br \/>\n| * 45b9122 feat B<br \/>\n| * f3b398d feat A<br \/>\n* | 15c7f3e main fix<br \/>\n|\/<br \/>\n* 812a70d base<\/p>\n<p>rebase \u4e4b\u540e\u7684\u5386\u53f2&#xff1a;<\/p>\n<p>* 214be71 feat B&#xff08;\u65b0\u54c8\u5e0c&#xff01;&#xff09;<br \/>\n* a937ce2 feat A&#xff08;\u65b0\u54c8\u5e0c&#xff01;&#xff09;<br \/>\n* 15c7f3e main fix<br \/>\n* 812a70d base<\/p>\n<p>\u767d\u8bdd\u7ffb\u8bd1&#xff1a;<\/p>\n<ul>\n<li>merge \u540e\u6709\u4e2a\u83f1\u5f62\u5206\u53c9&#xff0c;5a3b1c2 \u662f\u5408\u5e76\u63d0\u4ea4<\/li>\n<li>rebase \u540e\u4e00\u6761\u76f4\u7ebf&#xff0c;\u4f46 45b9122 \u53d8\u6210\u4e86 214be71&#xff0c;f3b398d \u53d8\u6210\u4e86 a937ce2\u2014\u2014\u540c\u6837\u7684\u4ee3\u7801\u6539\u52a8&#xff0c;\u4f46\u54c8\u5e0c\u503c\u4e0d\u540c\u4e86<\/li>\n<\/ul>\n<h4>2.3 \u5173\u952e\u8ba4\u77e5&#xff1a;rebase \u4f1a\u4ea7\u751f\u65b0\u63d0\u4ea4<\/h4>\n<p>rebase \u4e0d\u662f\u300c\u79fb\u52a8\u300d\u63d0\u4ea4&#xff0c;\u800c\u662f\u300c\u62c6\u6389\u91cd\u5efa\u300d\u3002<\/p>\n<p>\u6bcf\u4e2a\u65b0\u63d0\u4ea4\u7684\u54c8\u5e0c\u503c\u90fd\u548c\u539f\u6765\u4e0d\u540c&#xff0c;\u56e0\u4e3a&#xff1a;<\/p>\n<ul>\n<li>\u7236\u63d0\u4ea4\u53d8\u4e86&#xff08;\u4ece\u65e7\u57fa\u7ebf\u53d8\u6210\u65b0\u57fa\u7ebf&#xff09;\u2192 \u6574\u4e2a\u63d0\u4ea4\u7684\u54c8\u5e0c\u5c31\u53d8\u4e86<\/li>\n<li>\u54c8\u5e0c\u53d8\u4e86 \u2192 \u8fd9\u5c31\u662f\u4e00\u4e2a\u5168\u65b0\u7684\u63d0\u4ea4<\/li>\n<\/ul>\n<p>\u8fd9\u4e5f\u662f\u4e3a\u4ec0\u4e48\u5df2\u63a8\u9001\u7684\u63d0\u4ea4\u4e0d\u80fd rebase \u7684\u6839\u672c\u539f\u56e0&#xff1a;\u522b\u4eba\u5df2\u7ecf\u57fa\u4e8e\u65e7\u54c8\u5e0c\u5728\u5e72\u6d3b\u4e86&#xff0c;\u4f60\u5077\u5077\u6362\u6210\u65b0\u54c8\u5e0c&#xff0c;\u522b\u4eba\u7684\u4e16\u754c\u5c31\u5d29\u4e86\u3002<\/p>\n<h4>2.4 \u65b0\u624b\u6700\u5e38\u8e29\u7684\u5751<\/h4>\n<table>\n<tr>\u5751\u540e\u679c\u600e\u4e48\u907f<\/tr>\n<tbody>\n<tr>\n<td>\u5bf9\u5df2\u63a8\u9001\u7684\u5206\u652f\u6267\u884c rebase<\/td>\n<td>\u522b\u4eba\u62c9\u4ee3\u7801\u65f6\u51b2\u7a81\u5730\u72f1<\/td>\n<td>\u94c1\u5f8b&#xff1a;\u53ea\u5bf9\u81ea\u5df1\u7684\u672c\u5730\u5206\u652f rebase<\/td>\n<\/tr>\n<tr>\n<td>rebase \u8fc7\u7a0b\u4e2d\u614c\u4e86\u4e0d\u77e5\u9053\u600e\u4e48\u9000<\/td>\n<td>\u5361\u5728\u4e2d\u95f4\u72b6\u6001<\/td>\n<td>git rebase &#8211;abort \u4e00\u952e\u56de\u5230 rebase \u4e4b\u524d<\/td>\n<\/tr>\n<tr>\n<td>rebase \u51b2\u7a81\u65f6\u6ca1\u641e\u6e05\u8981\u4fdd\u7559\u4ec0\u4e48<\/td>\n<td>\u6539\u9519\u4e86\u66f4\u9ebb\u70e6<\/td>\n<td>\u51b2\u7a81\u6807\u8bb0\u548c merge \u4e00\u6837&#xff0c;\u5148\u770b\u61c2\u518d\u6539<\/td>\n<\/tr>\n<tr>\n<td>\u4ee5\u4e3a rebase \u80fd\u4ee3\u66ff\u4e00\u5207<\/td>\n<td>\u4e0d\u8be5 rebase \u7684\u5730\u65b9\u4e71\u7528<\/td>\n<td>\u516c\u5171\u5206\u652f\u7528 merge&#xff0c;\u79c1\u4eba\u7684\u529f\u80fd\u5206\u652f\u624d\u7528 rebase<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>3. \u5efa\u8bae\u5b66\u4e60\u987a\u5e8f<\/h3>\n<li>\u5148\u770b\u7b2c 2 \u8282\u641e\u61c2\u300c\u642c\u5bb6\u300d\u6bd4\u55bb<\/li>\n<li>\u8ddf\u7740\u7b2c 5 \u8282\u505a\u4e00\u904d\u57fa\u7840 rebase<\/li>\n<li>\u518d\u5b66\u4ea4\u4e92\u5f0f rebase<\/li>\n<li>\u6700\u540e\u5b66\u51b2\u7a81\u5904\u7406\u548c\u5b89\u5168\u89c4\u77e9<\/li>\n<hr \/>\n<h3>4. \u52a8\u624b\u51c6\u5907&#xff08;\u5efa\u53ef\u4e22\u5f03\u76ee\u5f55&#xff09;<\/h3>\n<p>\u8bf7\u627e\u4e00\u4e2a\u53ef\u4ee5\u968f\u4fbf\u5220\u7684\u7ec3\u4e60\u76ee\u5f55&#xff0c;\u4e0d\u8981\u7528\u6b63\u5728\u4ea4\u7684\u4f5c\u4e1a\u4ed3\u5e93\u7ec3\u624b\u3002<\/p>\n<p><span class=\"token function\">mkdir<\/span> lab-rebase<br \/>\n<span class=\"token builtin class-name\">cd<\/span> lab-rebase<br \/>\n<span class=\"token function\">git<\/span> init <span class=\"token parameter variable\">-b<\/span> main<br \/>\n<span class=\"token function\">git<\/span> config user.name <span class=\"token string\">&#034;Ada Example&#034;<\/span><br \/>\n<span class=\"token function\">git<\/span> config user.email <span class=\"token string\">&#034;ada&#064;example.com&#034;<\/span><\/p>\n<p>\u9a8c\u8bc1\u7248\u672c&#xff1a;<\/p>\n<p><span class=\"token function\">git<\/span> <span class=\"token parameter variable\">&#8211;version<\/span><\/p>\n<p>git version 2.43.0<\/p>\n<hr \/>\n<h3>5. \u8ddf\u7740\u505a&#xff1a;\u4e00\u6b21\u5b8c\u6574\u7684 rebase \u5b9e\u9a8c<\/h3>\n<h4>5.1 \u5148\u51c6\u5907\u4e24\u6761\u5206\u53c9\u7684\u5206\u652f<\/h4>\n<p><span class=\"token comment\"># \u5728 main \u4e0a\u5efa\u57fa\u7ebf<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;base content&#034;<\/span> <span class=\"token operator\">&gt;<\/span> file.txt<br \/>\n<span class=\"token function\">git<\/span> <span class=\"token function\">add<\/span> file.txt <span class=\"token operator\">&amp;&amp;<\/span> <span class=\"token function\">git<\/span> commit <span class=\"token parameter variable\">-m<\/span> <span class=\"token string\">&#034;base: \u521d\u59cb\u6587\u4ef6&#034;<\/span><\/p>\n<p><span class=\"token comment\"># main \u7ee7\u7eed\u524d\u8fdb&#xff1a;\u4fee\u4e00\u4e2a bug<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;bug fix from main&#034;<\/span> <span class=\"token operator\">&gt;&gt;<\/span> file.txt<br \/>\n<span class=\"token function\">git<\/span> <span class=\"token function\">add<\/span> file.txt <span class=\"token operator\">&amp;&amp;<\/span> <span class=\"token function\">git<\/span> commit <span class=\"token parameter variable\">-m<\/span> <span class=\"token string\">&#034;main: \u4fee\u590d\u4e00\u4e2a bug&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u56de\u5230\u5206\u53c9\u70b9&#xff0c;\u521b\u5efa\u529f\u80fd\u5206\u652f<\/span><br \/>\n<span class=\"token function\">git<\/span> checkout <span class=\"token parameter variable\">-b<\/span> feature 812a70d<\/p>\n<p>\u767d\u8bdd\u7ffb\u8bd1&#xff1a; -b feature \u521b\u5efa\u5e76\u5207\u6362\u5230 feature \u5206\u652f&#xff0c;812a70d \u662f\u5206\u53c9\u70b9\u3002<\/p>\n<p><span class=\"token comment\"># \u5728 feature \u5206\u652f\u4e0a\u505a\u4e24\u4e2a\u529f\u80fd\u63d0\u4ea4<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;feature A&#034;<\/span> <span class=\"token operator\">&gt;<\/span> feature-a.txt<br \/>\n<span class=\"token function\">git<\/span> <span class=\"token function\">add<\/span> feature-a.txt <span class=\"token operator\">&amp;&amp;<\/span> <span class=\"token function\">git<\/span> commit <span class=\"token parameter variable\">-m<\/span> <span class=\"token string\">&#034;feature: \u529f\u80fd A&#034;<\/span><\/p>\n<p><span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;feature B&#034;<\/span> <span class=\"token operator\">&gt;<\/span> feature-b.txt<br \/>\n<span class=\"token function\">git<\/span> <span class=\"token function\">add<\/span> feature-b.txt <span class=\"token operator\">&amp;&amp;<\/span> <span class=\"token function\">git<\/span> commit <span class=\"token parameter variable\">-m<\/span> <span class=\"token string\">&#034;feature: \u529f\u80fd B&#034;<\/span><\/p>\n<p>\u73b0\u5728\u770b\u770b\u5386\u53f2\u7ebf&#xff1a;<\/p>\n<p><span class=\"token function\">git<\/span> log <span class=\"token parameter variable\">&#8211;graph<\/span> <span class=\"token parameter variable\">&#8211;all<\/span> <span class=\"token parameter variable\">&#8211;oneline<\/span><\/p>\n<p>* 45b9122 feature: \u529f\u80fd B<br \/>\n* f3b398d feature: \u529f\u80fd A<br \/>\n| * 15c7f3e main: \u4fee\u590d\u4e00\u4e2a bug<br \/>\n|\/<br \/>\n* 812a70d base: \u521d\u59cb\u6587\u4ef6<\/p>\n<p>\u767d\u8bdd\u7ffb\u8bd1&#xff1a; |\/ \u5c31\u662f\u5206\u53c9\u70b9&#xff0c;\u4e24\u6761\u7ebf\u4ece 812a70d \u5206\u5f00\u3002<\/p>\n<h4>5.2 \u7528 merge \u5408\u5e76&#xff08;\u5148\u770b\u770b\u8001\u529e\u6cd5&#xff09;<\/h4>\n<p><span class=\"token function\">git<\/span> checkout main <span class=\"token operator\">&amp;&amp;<\/span> <span class=\"token function\">git<\/span> merge feature<\/p>\n<p><span class=\"token function\">git<\/span> log <span class=\"token parameter variable\">&#8211;graph<\/span> <span class=\"token parameter variable\">&#8211;all<\/span> <span class=\"token parameter variable\">&#8211;oneline<\/span><\/p>\n<p>*   5a3b1c2 Merge branch &#039;feature&#039;<br \/>\n|\\\\<br \/>\n| * 45b9122 feature: \u529f\u80fd B<br \/>\n| * f3b398d feature: \u529f\u80fd A<br \/>\n* | 15c7f3e main: \u4fee\u590d\u4e00\u4e2a bug<br \/>\n|\/<br \/>\n* 812a70d base: \u521d\u59cb\u6587\u4ef6<\/p>\n<p>\u767d\u8bdd\u7ffb\u8bd1&#xff1a; merge \u4ea7\u751f\u4e86\u4e00\u4e2a\u5408\u5e76\u63d0\u4ea4&#xff0c;\u5386\u53f2\u7ebf\u53d8\u6210\u4e86\u83f1\u5f62\u3002<\/p>\n<h4>5.3 \u64a4\u9500 merge&#xff0c;\u6539\u7528 rebase \u8bd5\u8bd5<\/h4>\n<p><span class=\"token comment\"># \u9000\u56de\u53bb<\/span><br \/>\n<span class=\"token function\">git<\/span> reset <span class=\"token parameter variable\">&#8211;hard<\/span> 15c7f3e<\/p>\n<p><span class=\"token comment\"># \u5207\u5230\u529f\u80fd\u5206\u652f\u5e76 rebase \u5230 main<\/span><br \/>\n<span class=\"token function\">git<\/span> checkout feature <span class=\"token operator\">&amp;&amp;<\/span> <span class=\"token function\">git<\/span> rebase main<\/p>\n<p>Successfully rebased and updated refs\/heads\/feature.<\/p>\n<p>\u770b\u770b\u73b0\u5728\u7684\u5386\u53f2\u7ebf&#xff1a;<\/p>\n<p><span class=\"token function\">git<\/span> log <span class=\"token parameter variable\">&#8211;graph<\/span> <span class=\"token parameter variable\">&#8211;all<\/span> <span class=\"token parameter variable\">&#8211;oneline<\/span><\/p>\n<p>* 7d4e8a3 feature: \u529f\u80fd B<br \/>\n* a937ce2 feature: \u529f\u80fd A<br \/>\n* 15c7f3e main: \u4fee\u590d\u4e00\u4e2a bug<br \/>\n* 812a70d base: \u521d\u59cb\u6587\u4ef6<\/p>\n<p>\u767d\u8bdd\u7ffb\u8bd1&#xff1a; \u4e00\u6761\u76f4\u7ebf&#xff01;\u529f\u80fd A \u548c B \u7684\u54c8\u5e0c\u90fd\u53d8\u4e86&#xff0c;\u662f\u300c\u65b0\u697c\u5c42\u4e0a\u91cd\u5efa\u7684\u65b0\u63d0\u4ea4\u300d\u3002<\/p>\n<h4>5.4 \u6700\u540e\u628a feature \u5408\u5e76\u8fdb main&#xff08;\u5feb\u8fdb\u5408\u5e76&#xff09;<\/h4>\n<p><span class=\"token function\">git<\/span> checkout main <span class=\"token operator\">&amp;&amp;<\/span> <span class=\"token function\">git<\/span> merge feature<\/p>\n<p>Updating 15c7f3e..7d4e8a3<br \/>\nFast-forward<\/p>\n<p>\u767d\u8bdd\u7ffb\u8bd1&#xff1a; Fast-forward \u8868\u793a\u5feb\u8fdb\u5408\u5e76&#xff0c;\u6ca1\u6709\u5408\u5e76\u63d0\u4ea4&#xff0c;\u5386\u53f2\u7ebf\u5b8c\u5168\u662f\u4e00\u6761\u76f4\u7ebf\u3002<\/p>\n<hr \/>\n<h3>6. \u547d\u4ee4\u5206\u7ec4&#xff08;\u6309\u573a\u666f\u5206\u7ec4&#xff09;<\/h3>\n<h4>6.1 \u57fa\u672c rebase&#xff08;\u65e5\u5e38\u6700\u5e38\u7528&#xff09;<\/h4>\n<table>\n<tr>\u547d\u4ee4\u5e72\u4ec0\u4e48<\/tr>\n<tbody>\n<tr>\n<td>git rebase main<\/td>\n<td>\u628a\u5f53\u524d\u5206\u652f\u7684\u63d0\u4ea4\u642c\u5230 main \u7684\u6700\u65b0\u4ee3\u7801\u4e0a\u9762<\/td>\n<\/tr>\n<tr>\n<td>git rebase main feature<\/td>\n<td>\u4e0d\u7ba1\u5f53\u524d\u5728\u54ea\u4e2a\u5206\u652f&#xff0c;\u628a feature \u642c\u5230 main \u4e0a\u9762<\/td>\n<\/tr>\n<tr>\n<td>git rebase &#8211;abort<\/td>\n<td>\u653e\u5f03\u6574\u4e2a rebase&#xff0c;\u56de\u5230 rebase \u4e4b\u524d<\/td>\n<\/tr>\n<tr>\n<td>git rebase &#8211;continue<\/td>\n<td>\u89e3\u51b3\u51b2\u7a81\u540e&#xff0c;\u7ee7\u7eed\u6267\u884c\u5269\u4f59\u7684 rebase \u6b65\u9aa4<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>6.2 \u4ea4\u4e92\u5f0f rebase&#xff08;\u6539\u5199\u63d0\u4ea4\u5386\u53f2&#xff09;<\/h4>\n<table>\n<tr>\u547d\u4ee4\u5e72\u4ec0\u4e48<\/tr>\n<tbody>\n<tr>\n<td>git rebase -i HEAD~3<\/td>\n<td>\u4ea4\u4e92\u5f0f\u91cd\u505a\u6700\u8fd1 3 \u4e2a\u63d0\u4ea4<\/td>\n<\/tr>\n<tr>\n<td>git rebase -i main<\/td>\n<td>\u4ea4\u4e92\u5f0f\u628a\u5f53\u524d\u5206\u652f\u642c\u5230 main \u4e0a\u9762&#xff0c;\u540c\u65f6\u53ef\u4ee5\u6539\u5199\u6bcf\u4e2a\u63d0\u4ea4<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4ea4\u4e92\u5f0f rebase \u91cc\u53ef\u4ee5\u7528\u7684\u52a8\u4f5c&#xff1a;<\/p>\n<table>\n<tr>\u52a8\u4f5c\u7f29\u5199\u5e72\u4ec0\u4e48<\/tr>\n<tbody>\n<tr>\n<td>pick<\/td>\n<td>p<\/td>\n<td>\u4fdd\u7559\u8fd9\u4e2a\u63d0\u4ea4&#xff0c;\u539f\u6837\u5e94\u7528<\/td>\n<\/tr>\n<tr>\n<td>reword<\/td>\n<td>r<\/td>\n<td>\u4fdd\u7559\u4ee3\u7801\u6539\u52a8&#xff0c;\u4f46\u4fee\u6539\u63d0\u4ea4\u4fe1\u606f<\/td>\n<\/tr>\n<tr>\n<td>squash<\/td>\n<td>s<\/td>\n<td>\u628a\u8fd9\u4e2a\u63d0\u4ea4\u548c\u524d\u4e00\u4e2a\u5408\u5e76\u6210\u4e00\u6761<\/td>\n<\/tr>\n<tr>\n<td>fixup<\/td>\n<td>f<\/td>\n<td>\u548c squash \u4e00\u6837&#xff0c;\u4f46\u4e22\u5f03\u8fd9\u4e2a\u63d0\u4ea4\u7684\u4fe1\u606f<\/td>\n<\/tr>\n<tr>\n<td>drop<\/td>\n<td>d<\/td>\n<td>\u76f4\u63a5\u6254\u6389\u8fd9\u4e2a\u63d0\u4ea4<\/td>\n<\/tr>\n<tr>\n<td>edit<\/td>\n<td>e<\/td>\n<td>\u5728\u8fd9\u4e2a\u63d0\u4ea4\u5904\u6682\u505c&#xff0c;\u4f60\u53ef\u4ee5\u6539\u4ee3\u7801\u540e\u518d\u7ee7\u7eed<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>6.3 \u53d6\u6d88\u548c\u633d\u6551<\/h4>\n<table>\n<tr>\u547d\u4ee4\u5e72\u4ec0\u4e48<\/tr>\n<tbody>\n<tr>\n<td>git rebase &#8211;abort<\/td>\n<td>\u653e\u5f03\u672c\u6b21 rebase&#xff0c;\u56de\u5230 rebase \u4e4b\u524d<\/td>\n<\/tr>\n<tr>\n<td>git rebase &#8211;skip<\/td>\n<td>\u8df3\u8fc7\u5f53\u524d\u6b63\u5728\u5904\u7406\u7684\u63d0\u4ea4&#xff08;\u614e\u7528&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>git reflog<\/td>\n<td>\u67e5\u770b HEAD \u7684\u79fb\u52a8\u5386\u53f2&#xff0c;\u627e\u56de rebase \u4e4b\u524d\u7684\u65e7\u63d0\u4ea4<\/td>\n<\/tr>\n<tr>\n<td>git reset &#8211;hard \u65e7\u54c8\u5e0c<\/td>\n<td>\u7528 reflog \u627e\u5230\u65e7\u54c8\u5e0c\u540e&#xff0c;\u56de\u9000\u5230 rebase \u4e4b\u524d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>7. \u5bf9\u7167\u8868&#xff08;\u524d\u540e\u5bf9\u6bd4 \/ \u9009\u9879\u5bf9\u6bd4&#xff09;<\/h3>\n<h4>7.1 rebase vs merge&#xff1a;\u4ec0\u4e48\u65f6\u5019\u7528\u54ea\u4e2a<\/h4>\n<table>\n<tr>\u573a\u666f\u7528 rebase\u7528 merge<\/tr>\n<tbody>\n<tr>\n<td>\u81ea\u5df1\u7684\u529f\u80fd\u5206\u652f\u8981\u540c\u6b65\u4e3b\u5206\u652f\u7684\u6700\u65b0\u4ee3\u7801<\/td>\n<td>\u63a8\u8350\u2014\u2014\u5386\u53f2\u66f4\u5e72\u51c0<\/td>\n<td>\u4e5f\u884c&#xff0c;\u4f46\u4f1a\u6709\u5408\u5e76\u63d0\u4ea4<\/td>\n<\/tr>\n<tr>\n<td>\u628a\u529f\u80fd\u5206\u652f\u5408\u8fdb main<\/td>\n<td>\u5148 rebase \u518d\u5feb\u8fdb\u5408\u5e76<\/td>\n<td>\u76f4\u63a5 merge \u4e5f\u5b8c\u5168\u53ef\u4ee5<\/td>\n<\/tr>\n<tr>\n<td>\u591a\u4eba\u540c\u65f6\u5728\u7528\u7684\u516c\u5171\u5206\u652f<\/td>\n<td>\u7edd\u5bf9\u4e0d\u8981<\/td>\n<td>\u7528 merge<\/td>\n<\/tr>\n<tr>\n<td>\u60f3\u4fdd\u7559\u300c\u540c\u65f6\u5f00\u53d1\u4e86\u4e24\u4e2a\u529f\u80fd\u300d\u8fd9\u4e00\u4e8b\u5b9e<\/td>\n<td>rebase \u4f1a\u4e22\u6389\u8fd9\u4e2a\u4fe1\u606f<\/td>\n<td>merge \u4fdd\u7559\u4e86\u5206\u53c9<\/td>\n<\/tr>\n<tr>\n<td>\u5f00\u6e90\u9879\u76ee\u63d0\u4ea4 PR<\/td>\n<td>\u5f88\u591a\u9879\u76ee\u8981\u6c42\u5148 rebase<\/td>\n<td>\u770b\u9879\u76ee\u89c4\u5b9a<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>7.2 \u4ea4\u4e92\u5f0f rebase \u7684\u52a8\u4f5c\u5bf9\u7167<\/h4>\n<table>\n<tr>\u4f60\u60f3\u5e72\u4ec0\u4e48\u9009\u4ec0\u4e48\u52a8\u4f5c\u4e3e\u4e2a\u4f8b\u5b50<\/tr>\n<tbody>\n<tr>\n<td>\u8fd9\u4e2a\u63d0\u4ea4\u6ca1\u95ee\u9898&#xff0c;\u539f\u6837\u4fdd\u7559<\/td>\n<td>pick<\/td>\n<td>\u9ed8\u8ba4\u5c31\u662f pick<\/td>\n<\/tr>\n<tr>\n<td>\u63d0\u4ea4\u4fe1\u606f\u5199\u9519\u4e86\u60f3\u6539<\/td>\n<td>reword<\/td>\n<td>\u300cfix bug\u300d\u2192\u300c\u4fee\u590d\u767b\u5f55\u9875\u9762\u9a8c\u8bc1\u7801\u4e0d\u663e\u793a\u7684 bug\u300d<\/td>\n<\/tr>\n<tr>\n<td>3 \u4e2a\u5c0f\u63d0\u4ea4\u60f3\u5408\u6210 1 \u4e2a<\/td>\n<td>squash<\/td>\n<td>\u300c\u4fee typo\u300d\u300c\u53c8\u4fee\u300d\u300c\u518d\u4fee\u300d\u2192\u300c\u4fee\u590d\u6587\u6863\u4e2d\u7684\u62fc\u5199\u9519\u8bef\u300d<\/td>\n<\/tr>\n<tr>\n<td>\u548c\u524d\u4e00\u4e2a\u5408\u5e76&#xff0c;\u4f46\u4e0d\u8981\u8fd9\u4e2a\u63d0\u4ea4\u7684\u4fe1\u606f<\/td>\n<td>fixup<\/td>\n<td>\u4e2d\u95f4\u6b65\u9aa4\u7684\u63d0\u4ea4\u4fe1\u606f\u6ca1\u4ef7\u503c<\/td>\n<\/tr>\n<tr>\n<td>\u8fd9\u4e2a\u63d0\u4ea4\u4e0d\u8981\u4e86<\/td>\n<td>drop<\/td>\n<td>\u8bd5\u8bd5\u770b\u7684\u4ee3\u7801&#xff0c;\u540e\u6765\u6ca1\u7528\u4e0a<\/td>\n<\/tr>\n<tr>\n<td>\u60f3\u4fee\u6539\u8fd9\u4e2a\u63d0\u4ea4\u7684\u4ee3\u7801<\/td>\n<td>edit<\/td>\n<td>\u63d0\u4ea4\u91cc\u5c11\u6539\u4e86\u4e00\u4e2a\u6587\u4ef6&#xff0c;\u8865\u4e0a<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>7.3 \u51b2\u7a81\u6807\u8bb0\u5bf9\u7167<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260811005722-6a7a73720913b.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u56fe&#xff1a;\u51b2\u7a81\u6807\u8bb0\u957f\u8fd9\u6837\u3002<\/p>\n<table>\n<tr>\u6807\u8bb0\u542b\u4e49\u767d\u8bdd\u89e3\u91ca<\/tr>\n<tbody>\n<tr>\n<td>&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD<\/td>\n<td>\u5f53\u524d\u5206\u652f&#xff08;rebase \u65f6\u662f\u4f60\u6b63\u5728\u91cd\u653e\u7684\u63d0\u4ea4&#xff09;<\/td>\n<td>\u300c\u4f60\u300d\u7684\u7248\u672c<\/td>\n<\/tr>\n<tr>\n<td>&#061;&#061;&#061;&#061;&#061;&#061;&#061;<\/td>\n<td>\u5206\u9694\u7ebf<\/td>\n<td>\u4e0a\u9762\u662f\u4f60\u7684&#xff0c;\u4e0b\u9762\u662f\u522b\u4eba\u7684<\/td>\n<\/tr>\n<tr>\n<td>&gt;&gt;&gt;&gt;&gt;&gt;&gt; feature<\/td>\n<td>\u88ab\u5408\u5e76\u8fdb\u6765\u7684\u5206\u652f<\/td>\n<td>\u300c\u522b\u4eba\u300d\u7684\u7248\u672c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>8. \u5b89\u5168\u4e60\u60ef&#xff08;\u786c\u89c4\u77e9 &#043; \u8e29\u5751\u63d0\u9192&#xff09;<\/h3>\n<h4>8.1 \u5efa\u8bae\u8fd9\u6837\u505a<\/h4>\n<table>\n<tr>\u4e60\u60ef\u539f\u56e0<\/tr>\n<tbody>\n<tr>\n<td>\u53ea\u5bf9\u81ea\u5df1\u7684\u3001\u8fd8\u6ca1\u63a8\u9001\u7684\u5206\u652f\u505a rebase<\/td>\n<td>\u6ca1\u4eba\u57fa\u4e8e\u4f60\u7684\u65e7\u63d0\u4ea4\u5728\u5e72\u6d3b&#xff0c;\u6539\u5199\u5386\u53f2\u4e0d\u4f1a\u5f71\u54cd\u522b\u4eba<\/td>\n<\/tr>\n<tr>\n<td>rebase \u4e4b\u524d\u5148 git status \u786e\u8ba4\u5de5\u4f5c\u533a\u5e72\u51c0<\/td>\n<td>\u810f\u5de5\u4f5c\u533a\u4f1a\u5bfc\u81f4 rebase \u51fa\u9519\u6216\u4e2d\u9014\u5361\u4f4f<\/td>\n<\/tr>\n<tr>\n<td>rebase \u4e4b\u524d\u5148\u770b\u4e00\u4e0b\u5206\u652f\u7ebf git log &#8211;graph<\/td>\n<td>\u786e\u8ba4\u4f60\u77e5\u9053\u8981 rebase \u7684\u8303\u56f4<\/td>\n<\/tr>\n<tr>\n<td>\u51b2\u7a81\u65f6\u51b7\u9759\u770b\u6807\u8bb0&#xff0c;\u60f3\u6e05\u695a\u8981\u4fdd\u7559\u4ec0\u4e48<\/td>\n<td>\u522b\u6025\u7740\u5220&#xff0c;\u5148\u7406\u89e3<\/td>\n<\/tr>\n<tr>\n<td>rebase \u5931\u8d25\u4e86\u5148 &#8211;abort<\/td>\n<td>\u56de\u5230\u539f\u70b9\u91cd\u65b0\u6765&#xff0c;\u6bd4\u786c\u7740\u5934\u76ae\u8d70\u4e0b\u53bb\u5b89\u5168<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>8.2 \u7edd\u5bf9\u4e0d\u8981\u8fd9\u6837\u505a<\/h4>\n<table>\n<tr>\u7981\u6b62\u64cd\u4f5c\u540e\u679c<\/tr>\n<tbody>\n<tr>\n<td>\u5bf9\u5df2\u63a8\u9001\u5230\u8fdc\u7a0b\u7684\u516c\u5171\u5206\u652f\u6267\u884c rebase<\/td>\n<td>\u522b\u4eba\u7684\u672c\u5730\u5386\u53f2\u548c\u4f60\u4e0d\u4e00\u6837\u4e86&#xff0c;\u62c9\u4ee3\u7801\u65f6\u51b2\u7a81\u5730\u72f1<\/td>\n<\/tr>\n<tr>\n<td>\u5728 rebase \u4e2d\u9014\u7528 &#8211;skip \u968f\u610f\u8df3\u8fc7\u63d0\u4ea4<\/td>\n<td>\u4f60\u8df3\u8fc7\u7684\u90a3\u4e2a\u63d0\u4ea4\u7684\u4ee3\u7801\u6539\u52a8\u5c31\u4e22\u4e86<\/td>\n<\/tr>\n<tr>\n<td>rebase \u65f6\u9047\u5230\u51b2\u7a81\u76f4\u63a5 git add . &#043; git rebase &#8211;continue<\/td>\n<td>\u4e0d\u770b\u51b2\u7a81\u5185\u5bb9\u5c31\u5168\u76d8\u63a5\u53d7&#xff0c;\u53ef\u80fd\u8986\u76d6\u6389\u522b\u4eba\u7684\u4ee3\u7801<\/td>\n<\/tr>\n<tr>\n<td>\u540c\u65f6\u5f00\u4e24\u4e2a\u7ec8\u7aef\u5bf9\u540c\u4e00\u4e2a\u4ed3\u5e93\u505a rebase<\/td>\n<td>Git \u4f1a\u6253\u67b6&#xff0c;\u72b6\u6001\u4e71\u6210\u4e00\u9505\u7ca5<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u94c1\u5f8b&#xff1a;\u6c38\u8fdc\u4e0d\u8981 rebase \u5df2\u7ecf\u63a8\u9001\u5230\u5171\u4eab\u5206\u652f\u4e0a\u7684\u63d0\u4ea4\u3002 \u8fdd\u53cd\u8fd9\u6761\u89c4\u5219\u7684\u540e\u679c\u662f&#xff1a;\u56e2\u961f\u6210\u5458\u62c9\u4ee3\u7801\u65f6\u4f1a\u53d1\u73b0\u5386\u53f2\u5bf9\u4e0d\u4e0a&#xff0c;\u8981\u4e48\u5408\u4e0d\u51fa\u6765&#xff0c;\u8981\u4e48\u91cd\u590d\u63d0\u4ea4\u6ee1\u5929\u98de\u3002\u5982\u679c\u4e00\u5b9a\u8981\u6539\u5df2\u63a8\u9001\u7684\u5386\u53f2&#xff0c;\u5fc5\u987b\u548c\u6240\u6709\u76f8\u5173\u7684\u4eba\u534f\u8c03\u597d&#xff0c;\u800c\u4e14\u8981\u7528 &#8211;force-with-lease \u800c\u4e0d\u662f &#8211;force\u3002<\/p>\n<h4>8.3 \u63a8\u8350\u7684\u6700\u5c0f\u6d41\u7a0b&#xff08;\u80cc\u4e0b\u6765&#xff09;<\/h4>\n<p><span class=\"token comment\"># 1. \u786e\u8ba4\u5728\u529f\u80fd\u5206\u652f\u4e0a<\/span><br \/>\n<span class=\"token function\">git<\/span> branch<br \/>\n<span class=\"token comment\"># 2. \u786e\u8ba4\u5de5\u4f5c\u533a\u5e72\u51c0<\/span><br \/>\n<span class=\"token function\">git<\/span> status<br \/>\n<span class=\"token comment\"># 3. \u770b\u4e00\u773c\u5f53\u524d\u5386\u53f2<\/span><br \/>\n<span class=\"token function\">git<\/span> log <span class=\"token parameter variable\">&#8211;oneline<\/span> <span class=\"token parameter variable\">-5<\/span><br \/>\n<span class=\"token comment\"># 4. \u6267\u884c rebase<\/span><br \/>\n<span class=\"token function\">git<\/span> rebase main<br \/>\n<span class=\"token comment\"># 5. \u5982\u679c\u6709\u51b2\u7a81&#xff1a;<\/span><br \/>\n<span class=\"token comment\">#    &#8211; \u6253\u5f00\u51b2\u7a81\u6587\u4ef6&#xff0c;\u770b &lt;&lt;&lt;&lt;&lt;&lt;&lt; \u548c &gt;&gt;&gt;&gt;&gt;&gt;&gt; \u4e4b\u95f4\u7684\u5185\u5bb9<\/span><br \/>\n<span class=\"token comment\">#    &#8211; \u624b\u52a8\u6539\u6210\u4f60\u60f3\u8981\u7684\u7ed3\u679c<\/span><br \/>\n<span class=\"token comment\">#    &#8211; git add \u51b2\u7a81\u6587\u4ef6<\/span><br \/>\n<span class=\"token comment\">#    &#8211; git rebase &#8211;continue<\/span><br \/>\n<span class=\"token comment\"># 6. \u5982\u679c\u641e\u7838\u4e86&#xff1a;<\/span><br \/>\n<span class=\"token comment\">#    &#8211; git rebase &#8211;abort&#xff08;\u56de\u5230\u7b2c 3 \u6b65\u7684\u72b6\u6001&#xff09;<\/span><br \/>\n<span class=\"token comment\"># 7. \u786e\u8ba4\u7ed3\u679c<\/span><br \/>\n<span class=\"token function\">git<\/span> log <span class=\"token parameter variable\">&#8211;graph<\/span> <span class=\"token parameter variable\">&#8211;oneline<\/span> <span class=\"token parameter variable\">-10<\/span><\/p>\n<hr \/>\n<h3>9. \u771f\u5b9e\u573a\u666f\u901f\u89c8<\/h3>\n<h4>9.1 \u8bfe\u7a0b\u5927\u4f5c\u4e1a&#xff1a;\u529f\u80fd\u5206\u652f\u8981\u540c\u6b65\u4e3b\u5206\u652f<\/h4>\n<p>\u4f60\u548c\u7ec4\u5458\u534f\u4f5c\u5199\u5927\u4f5c\u4e1a&#xff0c;\u4f60\u7684 feature-login \u5206\u652f\u5199\u4e86\u4e24\u5929&#xff0c;Meanwhile \u7ec4\u5458\u5df2\u7ecf\u628a\u6ce8\u518c\u529f\u80fd\u5408\u5e76\u5230 main \u4e86\u3002<\/p>\n<p><span class=\"token function\">git<\/span> checkout feature-login <span class=\"token operator\">&amp;&amp;<\/span> <span class=\"token function\">git<\/span> rebase main<\/p>\n<p>\u4f60\u7684\u767b\u5f55\u529f\u80fd\u5c31\u300c\u642c\u300d\u5230\u5305\u542b\u6ce8\u518c\u529f\u80fd\u7684\u6700\u65b0\u4ee3\u7801\u4e0a\u9762\u4e86\u3002\u5982\u679c\u51b2\u7a81&#xff0c;\u6309\u7b2c 8 \u8282\u7684\u6d41\u7a0b\u89e3\u51b3\u3002<\/p>\n<h4>9.2 \u63d0\u4ea4\u592a\u591a\u592a\u788e&#xff0c;\u63d0\u4ea4\u524d\u60f3\u6574\u7406<\/h4>\n<p>\u4f60\u5199\u4ee3\u7801\u65f6\u4e60\u60ef\u6bcf\u6539\u4e00\u70b9\u5c31 commit \u4e00\u6b21&#xff0c;\u73b0\u5728 git log \u4e00\u770b\u6709 8 \u4e2a\u63d0\u4ea4&#xff0c;\u4fe1\u606f\u5168\u662f\u300c\u6539\u4e86\u70b9\u4e1c\u897f\u300d\u300c\u518d\u6539\u6539\u300d\u300c\u5e94\u8be5\u597d\u4e86\u300d\u3002<\/p>\n<p><span class=\"token function\">git<\/span> rebase <span class=\"token parameter variable\">-i<\/span> HEAD~8<\/p>\n<p>\u5728\u7f16\u8f91\u5668\u91cc\u628a 8 \u4e2a\u63d0\u4ea4\u7684 pick \u6539\u6210&#xff1a;<\/p>\n<p>pick a1b2c3d \u5b9e\u73b0\u767b\u5f55\u9a8c\u8bc1<br \/>\nsquash e4f5g6h \u6539\u4e86\u70b9\u4e1c\u897f<br \/>\nsquash i7j8k9l \u518d\u6539\u6539<br \/>\nsquash m0n1o2p \u5e94\u8be5\u597d\u4e86<br \/>\npick q3r4s5t \u5b9e\u73b0\u6ce8\u518c\u9875\u9762<br \/>\nsquash t5u6v7w \u4fee\u4e86\u6ce8\u518c\u7684 typo<br \/>\nsquash w8x9y0z \u53c8\u4fee<br \/>\ndrop a1b2c3e \u8fd9\u6b21\u6539\u6ca1\u7528<\/p>\n<p>\u4fdd\u5b58\u9000\u51fa\u540e&#xff0c;Git \u4f1a\u4f9d\u6b21\u5904\u7406&#xff1a;\u524d 4 \u4e2a\u5408\u6210 1 \u4e2a&#xff0c;\u7b2c 5-7 \u4e2a\u5408\u6210 1 \u4e2a&#xff0c;\u7b2c 8 \u4e2a\u76f4\u63a5\u5220\u6389\u3002\u6700\u7ec8 8 \u4e2a\u63d0\u4ea4\u53d8\u6210 2 \u4e2a&#xff0c;\u5e72\u5e72\u51c0\u51c0\u3002<\/p>\n<h4>9.3 \u4ee3\u7801\u5ba1\u67e5\u524d\u6574\u7406\u5386\u53f2<\/h4>\n<p>\u63d0 PR \u4e4b\u524d&#xff0c;\u7528 git rebase -i \u628a\u96f6\u788e\u7684\u63d0\u4ea4\u538b\u7f29\u6210\u51e0\u4e2a\u6709\u610f\u4e49\u7684\u63d0\u4ea4\u3002\u6539\u5b8c\u4e4b\u540e force push \u5230\u4f60\u81ea\u5df1\u7684 fork\u3002<\/p>\n<p><span class=\"token function\">git<\/span> rebase <span class=\"token parameter variable\">-i<\/span> main<br \/>\n<span class=\"token comment\"># \u6574\u7406\u597d\u4e4b\u540e<\/span><br \/>\n<span class=\"token function\">git<\/span> push &#8211;force-with-lease origin feature-branch<\/p>\n<p>&#8211;force-with-lease \u6bd4 &#8211;force \u5b89\u5168\u2014\u2014\u5982\u679c\u522b\u4eba\u5728\u4f60\u4e4b\u540e\u4e5f\u63a8\u4e86\u4ee3\u7801&#xff0c;\u5b83\u4f1a\u62d2\u7edd\u63a8\u9001&#xff0c;\u4e0d\u4f1a\u8986\u76d6\u522b\u4eba\u7684\u5de5\u4f5c\u3002<\/p>\n<hr \/>\n<h3>10. \u8fdb\u9636\u8865\u5145&#xff08;\u9009\u8bfb&#xff09;<\/h3>\n<li>rebase \u7684\u5e95\u5c42\u539f\u7406&#xff1a; rebase \u5176\u5b9e\u662f\u4e00\u8fde\u4e32 git cherry-pick\u3002\u5b83\u627e\u5230\u5206\u53c9\u70b9\u540e&#xff0c;\u4f9d\u6b21\u628a\u4f60\u5206\u652f\u4e0a\u7684\u6bcf\u4e2a\u63d0\u4ea4\u300c\u6458\u300d\u4e0b\u6765&#xff0c;\u5728\u65b0\u57fa\u7ebf\u4e0a\u91cd\u65b0\u300c\u79cd\u300d\u4e0a\u53bb\u3002<\/li>\n<li>onto \u53c2\u6570&#xff1a; git rebase &#8211;onto new-base upstream branch \u53ef\u4ee5\u628a branch \u4e0a\u4ece upstream \u4e4b\u540e\u7684\u63d0\u4ea4\u642c\u5230 new-base \u4e0a&#xff0c;\u9002\u5408\u4ece\u4e00\u4e2a\u5927\u529f\u80fd\u5206\u652f\u91cc\u300c\u5207\u300d\u51fa\u4e00\u90e8\u5206\u63d0\u4ea4\u3002<\/li>\n<li>Autosquash&#xff1a; \u5982\u679c\u4f60\u63d0\u4ea4\u65f6\u7528\u4e86 git commit &#8211;fixup&#061;\u54c8\u5e0c \u6216 &#8211;squash&#061;\u54c8\u5e0c&#xff0c;rebase \u65f6\u52a0 &#8211;autosquash \u53c2\u6570&#xff0c;Git \u4f1a\u81ea\u52a8\u628a fixup \u63d0\u4ea4\u653e\u5230\u5bf9\u5e94\u7684\u76ee\u6807\u63d0\u4ea4\u65c1\u8fb9\u3002<\/li>\n<li>rebase \u548c merge \u53ef\u4ee5\u5171\u5b58&#xff1a; \u56e2\u961f\u91cc\u5e38\u7528\u7684\u5de5\u4f5c\u6d41\u662f\u300c\u672c\u5730\u7528 rebase \u4fdd\u6301\u76f4\u7ebf&#xff0c;\u5408\u8fdb main \u65f6\u7528 merge \u4fdd\u7559\u5206\u53c9\u8bb0\u5f55\u300d\u3002\u4e0d\u7528\u975e\u6b64\u5373\u5f7c\u3002<\/li>\n<hr \/>\n<h3>11. \u5c0f\u5b9e\u9a8c&#xff08;\u52a8\u624b\u7ec3\u4e60 &#043; \u901a\u8fc7\u6807\u51c6&#xff09;<\/h3>\n<h4>\u5b9e\u9a8c\u7532&#xff1a;\u57fa\u7840 rebase\u2014\u2014\u628a\u5206\u53c9\u53d8\u6210\u76f4\u7ebf<\/h4>\n<li>\u5efa\u4e00\u4e2a\u53ef\u4e22\u5f03\u76ee\u5f55&#xff0c;\u5728 main \u4e0a\u63d0\u4ea4\u4e00\u4e2a\u57fa\u7ebf\u6587\u4ef6<\/li>\n<li>main \u4e0a\u518d\u63d0\u4ea4\u4e00\u6b21&#xff08;\u6bd4\u5982\u4fee\u4e2a bug&#xff09;<\/li>\n<li>\u4ece\u57fa\u7ebf\u5904\u521b\u5efa feature \u5206\u652f&#xff0c;\u505a\u4e24\u4e2a\u529f\u80fd\u63d0\u4ea4<\/li>\n<li>\u7528 git log &#8211;graph &#8211;all &#8211;oneline \u786e\u8ba4\u770b\u5230\u5206\u53c9<\/li>\n<li>\u5728 feature \u5206\u652f\u4e0a\u6267\u884c git rebase main<\/li>\n<li>\u518d\u770b git log &#8211;graph &#8211;all &#8211;oneline&#xff0c;\u786e\u8ba4\u53d8\u6210\u4e00\u6761\u76f4\u7ebf<\/li>\n<p>\u901a\u8fc7\u6807\u51c6&#xff1a; rebase \u540e\u5386\u53f2\u7ebf\u662f\u4e00\u6761\u76f4\u7ebf&#xff0c;\u6ca1\u6709\u5408\u5e76\u63d0\u4ea4&#xff0c;\u529f\u80fd\u63d0\u4ea4\u7684\u54c8\u5e0c\u503c\u53d8\u4e86\u3002<\/p>\n<h4>\u5b9e\u9a8c\u4e59&#xff1a;\u4ea4\u4e92\u5f0f rebase\u2014\u2014\u538b\u7f29\u63d0\u4ea4<\/h4>\n<li>\u5728\u4e00\u4e2a\u5206\u652f\u4e0a\u8fde\u7eed\u63d0\u4ea4 3 \u6b21&#xff0c;\u4fe1\u606f\u5206\u522b\u662f\u300c\u6b65\u9aa4\u4e00\u300d\u300c\u6b65\u9aa4\u4e8c\u300d\u300c\u6b65\u9aa4\u4e09\u300d<\/li>\n<li>\u6267\u884c git rebase -i HEAD~3<\/li>\n<li>\u628a\u7b2c\u4e8c\u4e2a\u548c\u7b2c\u4e09\u4e2a\u7684 pick \u6539\u6210 squash<\/li>\n<li>\u5728\u5f39\u51fa\u7684\u7f16\u8f91\u5668\u91cc\u7f16\u8f91\u5408\u5e76\u540e\u7684\u63d0\u4ea4\u4fe1\u606f<\/li>\n<li>\u786e\u8ba4 git log &#8211;oneline \u53ea\u5269 1 \u4e2a\u63d0\u4ea4<\/li>\n<p>\u901a\u8fc7\u6807\u51c6&#xff1a; 3 \u4e2a\u63d0\u4ea4\u538b\u7f29\u6210 1 \u4e2a&#xff0c;\u4ee3\u7801\u5185\u5bb9\u4e0d\u53d8\u3002<\/p>\n<h4>\u5b9e\u9a8c\u4e19&#xff1a;rebase \u51b2\u7a81\u89e3\u51b3<\/h4>\n<li>\u5728 main \u548c feature \u5206\u652f\u4e0a\u4fee\u6539\u540c\u4e00\u4e2a\u6587\u4ef6\u7684\u540c\u4e00\u884c&#xff0c;\u5199\u4e0d\u540c\u5185\u5bb9<\/li>\n<li>\u5728 feature \u5206\u652f\u4e0a\u6267\u884c git rebase main<\/li>\n<li>\u770b\u5230\u51b2\u7a81\u63d0\u793a\u540e&#xff0c;\u6253\u5f00\u6587\u4ef6\u67e5\u770b &lt;&lt;&lt;&lt;&lt;&lt;&lt; \u6807\u8bb0<\/li>\n<li>\u624b\u52a8\u89e3\u51b3\u51b2\u7a81&#xff08;\u4fdd\u7559\u4f60\u60f3\u8981\u7684\u5185\u5bb9&#xff0c;\u5220\u6389\u6807\u8bb0&#xff09;<\/li>\n<li>git add \u51b2\u7a81\u6587\u4ef6&#xff0c;\u7136\u540e git rebase &#8211;continue<\/li>\n<li>\u786e\u8ba4 rebase \u5b8c\u6210&#xff0c;\u5386\u53f2\u7ebf\u662f\u76f4\u7ebf<\/li>\n<p>\u901a\u8fc7\u6807\u51c6&#xff1a; \u80fd\u72ec\u7acb\u4ece\u51b2\u7a81\u72b6\u6001\u8d70\u5230 rebase \u5b8c\u6210&#xff0c;\u6700\u7ec8\u4ee3\u7801\u662f\u4f60\u671f\u671b\u7684\u5185\u5bb9\u3002<\/p>\n<h4>\u5b9e\u9a8c\u4e01&#xff1a;rebase abort\u2014\u2014\u968f\u65f6\u80fd\u8dd1<\/h4>\n<li>\u5236\u9020\u4e00\u4e2a rebase \u51b2\u7a81&#xff08;\u540c\u5b9e\u9a8c\u4e19\u524d\u4e24\u6b65&#xff09;<\/li>\n<li>\u770b\u5230\u51b2\u7a81\u540e&#xff0c;\u4e0d\u89e3\u51b3&#xff0c;\u76f4\u63a5\u6267\u884c git rebase &#8211;abort<\/li>\n<li>\u786e\u8ba4 git log &#8211;graph &#8211;oneline \u548c rebase \u4e4b\u524d\u4e00\u6a21\u4e00\u6837<\/li>\n<p>\u901a\u8fc7\u6807\u51c6&#xff1a; abort \u540e\u4ed3\u5e93\u5b8c\u6574\u56de\u5230 rebase \u4e4b\u524d\u7684\u72b6\u6001&#xff0c;\u6ca1\u6709\u4efb\u4f55\u6b8b\u7559\u3002<\/p>\n<hr \/>\n<h3>12. \u5e38\u89c1\u95ee\u9898 FAQ<\/h3>\n<p>\u95ee 1&#xff1a;rebase \u548c merge \u5230\u5e95\u54ea\u4e2a\u66f4\u597d&#xff1f; \u6ca1\u6709\u7edd\u5bf9\u7684\u597d\u574f\u3002merge \u4fdd\u7559\u771f\u5b9e\u5386\u53f2&#xff0c;rebase \u8ba9\u5386\u53f2\u66f4\u6574\u6d01\u3002\u81ea\u5df1\u7684\u529f\u80fd\u5206\u652f\u7528 rebase \u6574\u7406&#xff0c;\u5408\u8fdb\u516c\u5171\u5206\u652f\u7528 merge \u8bb0\u5f55\u3002\u4e24\u6761\u8def\u6700\u7ec8\u7684\u4ee3\u7801\u662f\u4e00\u6837\u7684\u3002<\/p>\n<p>\u95ee 2&#xff1a;\u4e3a\u4ec0\u4e48 rebase \u540e\u63d0\u4ea4\u7684\u54c8\u5e0c\u503c\u53d8\u4e86&#xff1f; \u56e0\u4e3a\u63d0\u4ea4\u7684\u54c8\u5e0c\u662f\u6839\u636e\u300c\u5185\u5bb9 &#043; \u7236\u63d0\u4ea4 &#043; \u4f5c\u8005\u4fe1\u606f &#043; \u65f6\u95f4\u300d\u7b97\u51fa\u6765\u7684\u3002rebase \u6539\u53d8\u4e86\u7236\u63d0\u4ea4&#xff0c;\u6240\u4ee5\u54c8\u5e0c\u5fc5\u7136\u4e0d\u540c\u3002\u4ee3\u7801\u6539\u52a8\u4e0d\u53d8&#xff0c;\u4f46\u63d0\u4ea4\u5bf9\u8c61\u662f\u5168\u65b0\u7684\u3002<\/p>\n<p>\u95ee 3&#xff1a;rebase \u5230\u4e00\u534a\u4e0d\u60f3\u505a\u4e86\u600e\u4e48\u529e&#xff1f; git rebase &#8211;abort&#xff0c;\u4e00\u79d2\u56de\u5230 rebase \u4e4b\u524d\u3002\u8fd9\u662f rebase \u7684\u5b89\u5168\u7f51&#xff0c;\u5927\u80c6\u7528\u3002<\/p>\n<p>\u95ee 4&#xff1a;\u6211\u5728 rebase \u65f6\u51b2\u7a81\u4e86&#xff0c;\u600e\u4e48\u77e5\u9053\u8be5\u4fdd\u7559\u8c01\u7684&#xff1f; &lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD \u548c &#061;&#061;&#061;&#061;&#061;&#061;&#061; \u4e4b\u95f4\u662f\u4f60\u5f53\u524d\u6b63\u5728\u91cd\u653e\u7684\u63d0\u4ea4\u7684\u4ee3\u7801&#xff0c;&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u548c &gt;&gt;&gt;&gt;&gt;&gt;&gt; \u4e4b\u95f4\u662f\u65b0\u57fa\u7ebf\u4e0a\u7684\u4ee3\u7801\u3002\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u51b3\u5b9a\u4fdd\u7559\u54ea\u90e8\u5206\u3002<\/p>\n<p>\u95ee 5&#xff1a;\u4ea4\u4e92\u5f0f rebase \u5f39\u51fa\u7684\u7f16\u8f91\u5668\u6211\u4e0d\u4f1a\u7528\u600e\u4e48\u529e&#xff1f; \u9ed8\u8ba4\u7f16\u8f91\u5668\u53ef\u80fd\u662f vim\u3002\u8fdb\u53bb\u540e\u6309 i \u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f&#xff0c;\u6539\u5b8c\u6309 Esc&#xff0c;\u8f93\u5165 :wq \u4fdd\u5b58\u9000\u51fa\u3002\u4e0d\u4e60\u60ef\u7684\u8bdd\u53ef\u4ee5\u8bbe\u7f6e\u7f16\u8f91\u5668&#xff1a;git config core.editor &#034;code &#8211;wait&#034;&#xff08;\u7528 VS Code&#xff09;\u6216 git config core.editor &#034;nano&#034;\u3002<\/p>\n<p>\u95ee 6&#xff1a;squash \u548c fixup \u6709\u4ec0\u4e48\u533a\u522b&#xff1f; squash \u4f1a\u628a\u4e24\u4e2a\u63d0\u4ea4\u7684\u63d0\u4ea4\u4fe1\u606f\u90fd\u4fdd\u7559&#xff0c;\u8ba9\u4f60\u7f16\u8f91\u5408\u5e76\u540e\u7684\u4fe1\u606f\u3002fixup \u76f4\u63a5\u4e22\u5f03\u88ab\u5408\u5e76\u63d0\u4ea4\u7684\u4fe1\u606f&#xff0c;\u53ea\u4fdd\u7559\u7b2c\u4e00\u4e2a\u63d0\u4ea4\u7684\u4fe1\u606f\u3002<\/p>\n<hr \/>\n<h3>13. \u603b\u7ed3<\/h3>\n<h4>13.1 \u4e00\u9875\u901f\u8bb0<\/h4>\n<table>\n<tr>\u70b9\u8bb0\u4f4f\u4ec0\u4e48<\/tr>\n<tbody>\n<tr>\n<td>rebase \u662f\u4ec0\u4e48<\/td>\n<td>\u628a\u4f60\u7684\u63d0\u4ea4\u300c\u642c\u5bb6\u300d\u5230\u65b0\u57fa\u7ebf\u4e0a\u9762&#xff0c;\u5386\u53f2\u53d8\u76f4\u7ebf<\/td>\n<\/tr>\n<tr>\n<td>\u548c merge \u7684\u533a\u522b<\/td>\n<td>merge \u4fdd\u7559\u5206\u53c9&#xff0c;rebase \u6539\u5199\u6210\u76f4\u7ebf&#xff1b;\u6700\u7ec8\u4ee3\u7801\u4e00\u6837<\/td>\n<\/tr>\n<tr>\n<td>\u54c8\u5e0c\u4f1a\u53d8<\/td>\n<td>\u642c\u5bb6 &#061; \u62c6\u6389\u91cd\u5efa&#xff0c;\u63d0\u4ea4\u662f\u65b0\u7684&#xff0c;\u54c8\u5e0c\u4e0d\u540c<\/td>\n<\/tr>\n<tr>\n<td>\u4ea4\u4e92\u5f0f rebase<\/td>\n<td>-i \u53c2\u6570&#xff0c;\u53ef\u4ee5 squash \/ reword \/ drop \/ reorder<\/td>\n<\/tr>\n<tr>\n<td>\u51b2\u7a81\u5904\u7406<\/td>\n<td>\u548c merge \u4e00\u6837\u770b\u6807\u8bb0&#xff0c;\u89e3\u51b3\u540e add &#043; &#8211;continue<\/td>\n<\/tr>\n<tr>\n<td>\u653e\u5f03 rebase<\/td>\n<td>git rebase &#8211;abort \u968f\u65f6\u9000\u56de<\/td>\n<\/tr>\n<tr>\n<td>\u94c1\u5f8b<\/td>\n<td>\u6c38\u8fdc\u4e0d\u8981 rebase \u5df2\u63a8\u9001\u5230\u5171\u4eab\u5206\u652f\u7684\u63d0\u4ea4<\/td>\n<\/tr>\n<tr>\n<td>\u4ec0\u4e48\u65f6\u5019\u7528<\/td>\n<td>\u81ea\u5df1\u7684\u672c\u5730\u529f\u80fd\u5206\u652f\u540c\u6b65\u4e3b\u5206\u652f \/ \u6574\u7406\u63d0\u4ea4 \/ \u4ee3\u7801\u5ba1\u67e5\u524d<\/td>\n<\/tr>\n<tr>\n<td>\u627e\u56de\u65e7\u63d0\u4ea4<\/td>\n<td>git reflog \u67e5\u770b&#xff0c;git reset &#8211;hard \u56de\u9000<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>13.2 \u601d\u7ef4\u5347\u534e<\/h4>\n<p>rebase \u6539\u5199\u7684\u662f\u300c\u5386\u53f2\u600e\u4e48\u8bb2\u300d&#xff0c;\u4e0d\u662f\u300c\u4ee3\u7801\u662f\u4ec0\u4e48\u300d\u3002<\/p>\n<p>\u540c\u6837\u7684\u4ee3\u7801&#xff0c;merge \u8bb2\u4e86\u4e00\u4e2a\u300c\u4e24\u6761\u8def\u6c47\u5408\u300d\u7684\u6545\u4e8b&#xff0c;rebase \u8bb2\u4e86\u4e00\u4e2a\u300c\u4e00\u8def\u5411\u4e0a\u300d\u7684\u6545\u4e8b\u3002\u6545\u4e8b\u4e0d\u540c&#xff0c;\u7ed3\u5c40\u4e00\u6837\u3002\u4f46\u8bb0\u4f4f&#xff1a;\u516c\u5171\u7684\u5386\u53f2\u4e0d\u80fd\u4f60\u4e00\u4e2a\u4eba\u5077\u5077\u6539\u5199\u2014\u2014\u6539\u6545\u4e8b\u4e4b\u524d&#xff0c;\u5148\u786e\u8ba4\u53ea\u6709\u4f60\u4e00\u4e2a\u4eba\u5728\u8bfb\u8fd9\u672c\u4e66\u3002<\/p>\n<h4>13.3 \u5ef6\u4f38\u9605\u8bfb<\/h4>\n<ul>\n<li>Pro Git \u4e2d\u6587\u7248 \u2014 \u53d8\u57fa<\/li>\n<li>Git \u5b98\u65b9\u6587\u6863 \u2014 git-rebase<\/li>\n<li>Git \u672f\u8bed\u8868<\/li>\n<\/ul>\n<p>\u547d\u4ee4\u8f93\u51fa\u6837\u4f8b\u9a8c\u8bc1\u73af\u5883&#xff1a;Git 2.43.0&#xff1b;\u6f14\u793a\u4f5c\u8005\u4fe1\u606f\u4e3a\u865a\u6784&#xff1a;Ada Example &lt;ada&#064;example.com&gt;\u3002<\/p>\n<h4>13.4 \u68c0\u67e5\u6e05\u5355<\/h4>\n<ul>\n<li class=\"task-list-item\"> \u80fd\u7528\u300c\u642c\u5bb6\u5230\u65b0\u697c\u5c42\u300d\u7684\u6bd4\u55bb\u89e3\u91ca rebase \u7ed9\u540c\u5b66\u542c<\/li>\n<li class=\"task-list-item\"> \u80fd\u8bf4\u51fa rebase \u548c merge \u7684 3 \u4e2a\u533a\u522b<\/li>\n<li class=\"task-list-item\"> \u80fd\u72ec\u7acb\u5b8c\u6210\u4e00\u6b21\u57fa\u7840 rebase&#xff08;\u4e0d\u5206\u53c9\u53d8\u6210\u76f4\u7ebf&#xff09;<\/li>\n<li class=\"task-list-item\"> \u80fd\u7528\u4ea4\u4e92\u5f0f rebase \u538b\u7f29\u591a\u4e2a\u63d0\u4ea4<\/li>\n<li class=\"task-list-item\"> \u9047\u5230 rebase \u51b2\u7a81\u4e0d\u614c&#xff0c;\u77e5\u9053\u5982\u4f55\u89e3\u51b3<\/li>\n<li class=\"task-list-item\"> \u77e5\u9053 &#8211;abort \u53ef\u4ee5\u968f\u65f6\u653e\u5f03 rebase<\/li>\n<li class=\"task-list-item\"> \u7262\u8bb0\u94c1\u5f8b&#xff1a;\u4e0d rebase \u5df2\u63a8\u9001\u5230\u5171\u4eab\u5206\u652f\u7684\u63d0\u4ea4<\/li>\n<li class=\"task-list-item\"> \u5b8c\u6210 4 \u4e2a\u5c0f\u5b9e\u9a8c<\/li>\n<\/ul>\n<hr \/>\n<p>rebase \u7ed9\u4e86\u4f60\u6539\u5199\u5386\u53f2\u7684\u8d85\u80fd\u529b&#xff0c;\u4f46\u300c\u80fd\u529b\u8d8a\u5927&#xff0c;\u8d23\u4efb\u8d8a\u5927\u300d\u2014\u2014\u53ea\u6539\u81ea\u5df1\u7684\u5386\u53f2&#xff0c;\u4e0d\u8981\u52a8\u522b\u4eba\u7684\u3002\u4e0b\u4e00\u7ae0\u6211\u4eec\u8bb2 reflog&#xff1a;\u5c31\u7b97 rebase \u7ffb\u8f66\u4e86&#xff0c;\u4e5f\u8fd8\u6709\u529e\u6cd5\u6551\u4eba\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5199\u5728\u524d\u9762&#xff1a;\u8fd9\u4e00\u7ae0\u8981\u89e3\u51b3\u4ec0\u4e48<br \/>\n\u5982\u679c\u4f60\u5df2\u7ecf\u4f1a\u4e86\u5206\u652f\u548c\u5408\u5e76&#xff0c;\u5fc3\u91cc\u53ef\u80fd\u8fd8\u6709\u4e00\u4e2a\u66f4\u5177\u4f53\u7684\u56f0\u60d1&#xff1a;\u6bcf\u6b21 merge \u90fd\u4f1a\u591a\u51fa\u4e00\u4e2a\u5408\u5e76\u63d0\u4ea4&#xff0c;\u5206\u652f\u7ebf\u7f20\u6210\u4e00\u56e2\u3002 \u6709\u6ca1\u6709\u529e\u6cd5\u628a\u4ee3\u7801\u6539\u52a8\u300c\u7406\u6210\u4e00\u6761\u76f4\u7ebf\u300d&#xff1f;<br \/>\n\u5b66\u5b8c\u540e&#xff0c;\u4f60\u5e94\u8be5\u80fd&#xff1a;<br \/>\n\u8bf4\u6e05\u695a rebase \u548c merge \u7684\u533a\u522b&#xff08;\u7528\u300c\u642c\u5bb6\u300d\u7684\u6bd4\u55bb&#xff09;\u7528 git rebase \u628a\u5206\u652f\u7ebf\u6574\u7406\u6210\u76f4\u7ebf\u7528 git rebase -i \u538b\u7f29\u3001<\/p>\n","protected":false},"author":2,"featured_media":92766,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[89],"topic":[],"class_list":["post-92768","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-git"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>16 \u2014 \u6539\u5199\u5386\u53f2 rebase\uff1a\u642c\u5bb6\u5230\u65b0\u697c\u5c42\uff0c\u4e0d\u662f\u5408\u5e76 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/92768.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"16 \u2014 \u6539\u5199\u5386\u53f2 rebase\uff1a\u642c\u5bb6\u5230\u65b0\u697c\u5c42\uff0c\u4e0d\u662f\u5408\u5e76 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u5199\u5728\u524d\u9762&#xff1a;\u8fd9\u4e00\u7ae0\u8981\u89e3\u51b3\u4ec0\u4e48 \u5982\u679c\u4f60\u5df2\u7ecf\u4f1a\u4e86\u5206\u652f\u548c\u5408\u5e76&#xff0c;\u5fc3\u91cc\u53ef\u80fd\u8fd8\u6709\u4e00\u4e2a\u66f4\u5177\u4f53\u7684\u56f0\u60d1&#xff1a;\u6bcf\u6b21 merge \u90fd\u4f1a\u591a\u51fa\u4e00\u4e2a\u5408\u5e76\u63d0\u4ea4&#xff0c;\u5206\u652f\u7ebf\u7f20\u6210\u4e00\u56e2\u3002 \u6709\u6ca1\u6709\u529e\u6cd5\u628a\u4ee3\u7801\u6539\u52a8\u300c\u7406\u6210\u4e00\u6761\u76f4\u7ebf\u300d&#xff1f; \u5b66\u5b8c\u540e&#xff0c;\u4f60\u5e94\u8be5\u80fd&#xff1a; \u8bf4\u6e05\u695a rebase \u548c merge \u7684\u533a\u522b&#xff08;\u7528\u300c\u642c\u5bb6\u300d\u7684\u6bd4\u55bb&#xff09;\u7528 git rebase \u628a\u5206\u652f\u7ebf\u6574\u7406\u6210\u76f4\u7ebf\u7528 git rebase -i \u538b\u7f29\u3001\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/92768.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-11T00:57:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260811005721-6a7a7371b3922.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/92768.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/92768.html\",\"name\":\"16 \u2014 \u6539\u5199\u5386\u53f2 rebase\uff1a\u642c\u5bb6\u5230\u65b0\u697c\u5c42\uff0c\u4e0d\u662f\u5408\u5e76 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-11T00:57:23+00:00\",\"dateModified\":\"2026-08-11T00:57:23+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/92768.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/92768.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/92768.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"16 \u2014 \u6539\u5199\u5386\u53f2 rebase\uff1a\u642c\u5bb6\u5230\u65b0\u697c\u5c42\uff0c\u4e0d\u662f\u5408\u5e76\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"16 \u2014 \u6539\u5199\u5386\u53f2 rebase\uff1a\u642c\u5bb6\u5230\u65b0\u697c\u5c42\uff0c\u4e0d\u662f\u5408\u5e76 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/92768.html","og_locale":"zh_CN","og_type":"article","og_title":"16 \u2014 \u6539\u5199\u5386\u53f2 rebase\uff1a\u642c\u5bb6\u5230\u65b0\u697c\u5c42\uff0c\u4e0d\u662f\u5408\u5e76 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u5199\u5728\u524d\u9762&#xff1a;\u8fd9\u4e00\u7ae0\u8981\u89e3\u51b3\u4ec0\u4e48 \u5982\u679c\u4f60\u5df2\u7ecf\u4f1a\u4e86\u5206\u652f\u548c\u5408\u5e76&#xff0c;\u5fc3\u91cc\u53ef\u80fd\u8fd8\u6709\u4e00\u4e2a\u66f4\u5177\u4f53\u7684\u56f0\u60d1&#xff1a;\u6bcf\u6b21 merge \u90fd\u4f1a\u591a\u51fa\u4e00\u4e2a\u5408\u5e76\u63d0\u4ea4&#xff0c;\u5206\u652f\u7ebf\u7f20\u6210\u4e00\u56e2\u3002 \u6709\u6ca1\u6709\u529e\u6cd5\u628a\u4ee3\u7801\u6539\u52a8\u300c\u7406\u6210\u4e00\u6761\u76f4\u7ebf\u300d&#xff1f; \u5b66\u5b8c\u540e&#xff0c;\u4f60\u5e94\u8be5\u80fd&#xff1a; \u8bf4\u6e05\u695a rebase \u548c merge \u7684\u533a\u522b&#xff08;\u7528\u300c\u642c\u5bb6\u300d\u7684\u6bd4\u55bb&#xff09;\u7528 git rebase \u628a\u5206\u652f\u7ebf\u6574\u7406\u6210\u76f4\u7ebf\u7528 git rebase -i \u538b\u7f29\u3001","og_url":"https:\/\/www.wsisp.com\/helps\/92768.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-11T00:57:23+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260811005721-6a7a7371b3922.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/92768.html","url":"https:\/\/www.wsisp.com\/helps\/92768.html","name":"16 \u2014 \u6539\u5199\u5386\u53f2 rebase\uff1a\u642c\u5bb6\u5230\u65b0\u697c\u5c42\uff0c\u4e0d\u662f\u5408\u5e76 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-11T00:57:23+00:00","dateModified":"2026-08-11T00:57:23+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/92768.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/92768.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/92768.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"16 \u2014 \u6539\u5199\u5386\u53f2 rebase\uff1a\u642c\u5bb6\u5230\u65b0\u697c\u5c42\uff0c\u4e0d\u662f\u5408\u5e76"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/92768","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=92768"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/92768\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/92766"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=92768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=92768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=92768"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=92768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}