文章目录

  • 01 基本用法
  • 02 应用场景
    • 2.1 合并子分支到主分支
    • 2.2 将某段提交复制到另个分支上
    • 2.3 合并多个提交为一个提交
    • 2.4 rebase 过程中有冲突,如何解决
    • 2.5 rebase 成功后,如何撤销

提醒:不要在多人合作的公共分支里使用 rebase,自己的开发分支除外。 在公共分支里使用 rebase 的话可能会影响其他小伙伴的工作噢!

01 基本用法

描述git rebase 可以理解为 重新设置基线 ,即 将当前分支重新设置开始点

原理解释:它需要基于一个分支(后面称该分支为公共分支)来设置当前分支的基线,将当前分支的开始时间轴 向后移动到 公共分支的最新跟踪提交最后面 ,这样当前分支就是公共分支的最新跟踪分支了。

白话文解释:rebase 会把当前分支的 commit 放到公共分支的最后面,所以叫变基。就好像从最新公共分支又重新拉出来这个分支一样~

举个例子:现有一个 master 主分支,小明要开发新需求从 master 拉取并创建了名为 dev 的新分支。而当小明开发完后需要合并到 master,但发现 master 相比之前多了一些变更。这时想要同步 master 的改动应该怎么办呢?如下图所示:

#mermaid-svg-22kwqxhvGlwI4QeO .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-22kwqxhvGlwI4QeO .label text{fill:#333}#mermaid-svg-22kwqxhvGlwI4QeO .node rect,#mermaid-svg-22kwqxhvGlwI4QeO .node circle,#mermaid-svg-22kwqxhvGlwI4QeO .node ellipse,#mermaid-svg-22kwqxhvGlwI4QeO .node polygon,#mermaid-svg-22kwqxhvGlwI4QeO .node path{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-22kwqxhvGlwI4QeO .node .label{text-align:center;fill:#333}#mermaid-svg-22kwqxhvGlwI4QeO .node.clickable{cursor:pointer}#mermaid-svg-22kwqxhvGlwI4QeO .arrowheadPath{fill:#333}#mermaid-svg-22kwqxhvGlwI4QeO .edgePath .path{stroke:#333;stroke-width:1.5px}#mermaid-svg-22kwqxhvGlwI4QeO .flowchart-link{stroke:#333;fill:none}#mermaid-svg-22kwqxhvGlwI4QeO .edgeLabel{background-color:#e8e8e8;text-align:center}#mermaid-svg-22kwqxhvGlwI4QeO .edgeLabel rect{opacity:0.9}#mermaid-svg-22kwqxhvGlwI4QeO .edgeLabel span{color:#333}#mermaid-svg-22kwqxhvGlwI4QeO .cluster rect{fill:#ffffde;stroke:#aa3;stroke-width:1px}#mermaid-svg-22kwqxhvGlwI4QeO .cluster text{fill:#333}#mermaid-svg-22kwqxhvGlwI4QeO div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:12px;background:#ffffde;border:1px solid #aa3;border-radius:2px;pointer-events:none;z-index:100}#mermaid-svg-22kwqxhvGlwI4QeO .actor{stroke:#ccf;fill:#ECECFF}#mermaid-svg-22kwqxhvGlwI4QeO text.actor>tspan{fill:#000;stroke:none}#mermaid-svg-22kwqxhvGlwI4QeO .actor-line{stroke:grey}#mermaid-svg-22kwqxhvGlwI4QeO .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333}#mermaid-svg-22kwqxhvGlwI4QeO .messageLine1{stroke-width:1.5;stroke-dasharray:2, 2;stroke:#333}#mermaid-svg-22kwqxhvGlwI4QeO #arrowhead path{fill:#333;stroke:#333}#mermaid-svg-22kwqxhvGlwI4QeO .sequenceNumber{fill:#fff}#mermaid-svg-22kwqxhvGlwI4QeO #sequencenumber{fill:#333}#mermaid-svg-22kwqxhvGlwI4QeO #crosshead path{fill:#333;stroke:#333}#mermaid-svg-22kwqxhvGlwI4QeO .messageText{fill:#333;stroke:#333}#mermaid-svg-22kwqxhvGlwI4QeO .labelBox{stroke:#ccf;fill:#ECECFF}#mermaid-svg-22kwqxhvGlwI4QeO .labelText,#mermaid-svg-22kwqxhvGlwI4QeO .labelText>tspan{fill:#000;stroke:none}#mermaid-svg-22kwqxhvGlwI4QeO .loopText,#mermaid-svg-22kwqxhvGlwI4QeO .loopText>tspan{fill:#000;stroke:none}#mermaid-svg-22kwqxhvGlwI4QeO .loopLine{stroke-width:2px;stroke-dasharray:2, 2;stroke:#ccf;fill:#ccf}#mermaid-svg-22kwqxhvGlwI4QeO .note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-22kwqxhvGlwI4QeO .noteText,#mermaid-svg-22kwqxhvGlwI4QeO .noteText>tspan{fill:#000;stroke:none}#mermaid-svg-22kwqxhvGlwI4QeO .activation0{fill:#f4f4f4;stroke:#666}#mermaid-svg-22kwqxhvGlwI4QeO .activation1{fill:#f4f4f4;stroke:#666}#mermaid-svg-22kwqxhvGlwI4QeO .activation2{fill:#f4f4f4;stroke:#666}#mermaid-svg-22kwqxhvGlwI4QeO .mermaid-main-font{font-family:"trebuchet ms", verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-22kwqxhvGlwI4QeO .section{stroke:none;opacity:0.2}#mermaid-svg-22kwqxhvGlwI4QeO .section0{fill:rgba(102,102,255,0.49)}#mermaid-svg-22kwqxhvGlwI4QeO .section2{fill:#fff400}#mermaid-svg-22kwqxhvGlwI4QeO .section1,#mermaid-svg-22kwqxhvGlwI4QeO .section3{fill:#fff;opacity:0.2}#mermaid-svg-22kwqxhvGlwI4QeO .sectionTitle0{fill:#333}#mermaid-svg-22kwqxhvGlwI4QeO .sectionTitle1{fill:#333}#mermaid-svg-22kwqxhvGlwI4QeO .sectionTitle2{fill:#333}#mermaid-svg-22kwqxhvGlwI4QeO .sectionTitle3{fill:#333}#mermaid-svg-22kwqxhvGlwI4QeO .sectionTitle{text-anchor:start;font-size:11px;text-height:14px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-22kwqxhvGlwI4QeO .grid .tick{stroke:#d3d3d3;opacity:0.8;shape-rendering:crispEdges}#mermaid-svg-22kwqxhvGlwI4QeO .grid .tick text{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-22kwqxhvGlwI4QeO .grid path{stroke-width:0}#mermaid-svg-22kwqxhvGlwI4QeO .today{fill:none;stroke:red;stroke-width:2px}#mermaid-svg-22kwqxhvGlwI4QeO .task{stroke-width:2}#mermaid-svg-22kwqxhvGlwI4QeO .taskText{text-anchor:middle;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-22kwqxhvGlwI4QeO .taskText:not([font-size]){font-size:11px}#mermaid-svg-22kwqxhvGlwI4QeO .taskTextOutsideRight{fill:#000;text-anchor:start;font-size:11px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-22kwqxhvGlwI4QeO .taskTextOutsideLeft{fill:#000;text-anchor:end;font-size:11px}#mermaid-svg-22kwqxhvGlwI4QeO .task.clickable{cursor:pointer}#mermaid-svg-22kwqxhvGlwI4QeO .taskText.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-22kwqxhvGlwI4QeO .taskTextOutsideLeft.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-22kwqxhvGlwI4QeO .taskTextOutsideRight.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-22kwqxhvGlwI4QeO .taskText0,#mermaid-svg-22kwqxhvGlwI4QeO .taskText1,#mermaid-svg-22kwqxhvGlwI4QeO .taskText2,#mermaid-svg-22kwqxhvGlwI4QeO .taskText3{fill:#fff}#mermaid-svg-22kwqxhvGlwI4QeO .task0,#mermaid-svg-22kwqxhvGlwI4QeO .task1,#mermaid-svg-22kwqxhvGlwI4QeO .task2,#mermaid-svg-22kwqxhvGlwI4QeO .task3{fill:#8a90dd;stroke:#534fbc}#mermaid-svg-22kwqxhvGlwI4QeO .taskTextOutside0,#mermaid-svg-22kwqxhvGlwI4QeO .taskTextOutside2{fill:#000}#mermaid-svg-22kwqxhvGlwI4QeO .taskTextOutside1,#mermaid-svg-22kwqxhvGlwI4QeO .taskTextOutside3{fill:#000}#mermaid-svg-22kwqxhvGlwI4QeO .active0,#mermaid-svg-22kwqxhvGlwI4QeO .active1,#mermaid-svg-22kwqxhvGlwI4QeO .active2,#mermaid-svg-22kwqxhvGlwI4QeO .active3{fill:#bfc7ff;stroke:#534fbc}#mermaid-svg-22kwqxhvGlwI4QeO .activeText0,#mermaid-svg-22kwqxhvGlwI4QeO .activeText1,#mermaid-svg-22kwqxhvGlwI4QeO .activeText2,#mermaid-svg-22kwqxhvGlwI4QeO .activeText3{fill:#000 !important}#mermaid-svg-22kwqxhvGlwI4QeO .done0,#mermaid-svg-22kwqxhvGlwI4QeO .done1,#mermaid-svg-22kwqxhvGlwI4QeO .done2,#mermaid-svg-22kwqxhvGlwI4QeO .done3{stroke:grey;fill:#d3d3d3;stroke-width:2}#mermaid-svg-22kwqxhvGlwI4QeO .doneText0,#mermaid-svg-22kwqxhvGlwI4QeO .doneText1,#mermaid-svg-22kwqxhvGlwI4QeO .doneText2,#mermaid-svg-22kwqxhvGlwI4QeO .doneText3{fill:#000 !important}#mermaid-svg-22kwqxhvGlwI4QeO .crit0,#mermaid-svg-22kwqxhvGlwI4QeO .crit1,#mermaid-svg-22kwqxhvGlwI4QeO .crit2,#mermaid-svg-22kwqxhvGlwI4QeO .crit3{stroke:#f88;fill:red;stroke-width:2}#mermaid-svg-22kwqxhvGlwI4QeO .activeCrit0,#mermaid-svg-22kwqxhvGlwI4QeO .activeCrit1,#mermaid-svg-22kwqxhvGlwI4QeO .activeCrit2,#mermaid-svg-22kwqxhvGlwI4QeO .activeCrit3{stroke:#f88;fill:#bfc7ff;stroke-width:2}#mermaid-svg-22kwqxhvGlwI4QeO .doneCrit0,#mermaid-svg-22kwqxhvGlwI4QeO .doneCrit1,#mermaid-svg-22kwqxhvGlwI4QeO .doneCrit2,#mermaid-svg-22kwqxhvGlwI4QeO .doneCrit3{stroke:#f88;fill:#d3d3d3;stroke-width:2;cursor:pointer;shape-rendering:crispEdges}#mermaid-svg-22kwqxhvGlwI4QeO .milestone{transform:rotate(45deg) scale(0.8, 0.8)}#mermaid-svg-22kwqxhvGlwI4QeO .milestoneText{font-style:italic}#mermaid-svg-22kwqxhvGlwI4QeO .doneCritText0,#mermaid-svg-22kwqxhvGlwI4QeO .doneCritText1,#mermaid-svg-22kwqxhvGlwI4QeO .doneCritText2,#mermaid-svg-22kwqxhvGlwI4QeO .doneCritText3{fill:#000 !important}#mermaid-svg-22kwqxhvGlwI4QeO .activeCritText0,#mermaid-svg-22kwqxhvGlwI4QeO .activeCritText1,#mermaid-svg-22kwqxhvGlwI4QeO .activeCritText2,#mermaid-svg-22kwqxhvGlwI4QeO .activeCritText3{fill:#000 !important}#mermaid-svg-22kwqxhvGlwI4QeO .titleText{text-anchor:middle;font-size:18px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-22kwqxhvGlwI4QeO g.classGroup text{fill:#9370db;stroke:none;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:10px}#mermaid-svg-22kwqxhvGlwI4QeO g.classGroup text .title{font-weight:bolder}#mermaid-svg-22kwqxhvGlwI4QeO g.clickable{cursor:pointer}#mermaid-svg-22kwqxhvGlwI4QeO g.classGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-22kwqxhvGlwI4QeO g.classGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-22kwqxhvGlwI4QeO .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5}#mermaid-svg-22kwqxhvGlwI4QeO .classLabel .label{fill:#9370db;font-size:10px}#mermaid-svg-22kwqxhvGlwI4QeO .relation{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-22kwqxhvGlwI4QeO .dashed-line{stroke-dasharray:3}#mermaid-svg-22kwqxhvGlwI4QeO #compositionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-22kwqxhvGlwI4QeO #compositionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-22kwqxhvGlwI4QeO #aggregationStart{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-22kwqxhvGlwI4QeO #aggregationEnd{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-22kwqxhvGlwI4QeO #dependencyStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-22kwqxhvGlwI4QeO #dependencyEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-22kwqxhvGlwI4QeO #extensionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-22kwqxhvGlwI4QeO #extensionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-22kwqxhvGlwI4QeO .commit-id,#mermaid-svg-22kwqxhvGlwI4QeO .commit-msg,#mermaid-svg-22kwqxhvGlwI4QeO .branch-label{fill:lightgrey;color:lightgrey;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-22kwqxhvGlwI4QeO .pieTitleText{text-anchor:middle;font-size:25px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-22kwqxhvGlwI4QeO .slice{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-22kwqxhvGlwI4QeO g.stateGroup text{fill:#9370db;stroke:none;font-size:10px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-22kwqxhvGlwI4QeO g.stateGroup text{fill:#9370db;fill:#333;stroke:none;font-size:10px}#mermaid-svg-22kwqxhvGlwI4QeO g.statediagram-cluster .cluster-label text{fill:#333}#mermaid-svg-22kwqxhvGlwI4QeO g.stateGroup .state-title{font-weight:bolder;fill:#000}#mermaid-svg-22kwqxhvGlwI4QeO g.stateGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-22kwqxhvGlwI4QeO g.stateGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-22kwqxhvGlwI4QeO .transition{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-22kwqxhvGlwI4QeO .stateGroup .composit{fill:white;border-bottom:1px}#mermaid-svg-22kwqxhvGlwI4QeO .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px}#mermaid-svg-22kwqxhvGlwI4QeO .state-note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-22kwqxhvGlwI4QeO .state-note text{fill:black;stroke:none;font-size:10px}#mermaid-svg-22kwqxhvGlwI4QeO .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.7}#mermaid-svg-22kwqxhvGlwI4QeO .edgeLabel text{fill:#333}#mermaid-svg-22kwqxhvGlwI4QeO .stateLabel text{fill:#000;font-size:10px;font-weight:bold;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-22kwqxhvGlwI4QeO .node circle.state-start{fill:black;stroke:black}#mermaid-svg-22kwqxhvGlwI4QeO .node circle.state-end{fill:black;stroke:white;stroke-width:1.5}#mermaid-svg-22kwqxhvGlwI4QeO #statediagram-barbEnd{fill:#9370db}#mermaid-svg-22kwqxhvGlwI4QeO .statediagram-cluster rect{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-22kwqxhvGlwI4QeO .statediagram-cluster rect.outer{rx:5px;ry:5px}#mermaid-svg-22kwqxhvGlwI4QeO .statediagram-state .divider{stroke:#9370db}#mermaid-svg-22kwqxhvGlwI4QeO .statediagram-state .title-state{rx:5px;ry:5px}#mermaid-svg-22kwqxhvGlwI4QeO .statediagram-cluster.statediagram-cluster .inner{fill:white}#mermaid-svg-22kwqxhvGlwI4QeO .statediagram-cluster.statediagram-cluster-alt .inner{fill:#e0e0e0}#mermaid-svg-22kwqxhvGlwI4QeO .statediagram-cluster .inner{rx:0;ry:0}#mermaid-svg-22kwqxhvGlwI4QeO .statediagram-state rect.basic{rx:5px;ry:5px}#mermaid-svg-22kwqxhvGlwI4QeO .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#efefef}#mermaid-svg-22kwqxhvGlwI4QeO .note-edge{stroke-dasharray:5}#mermaid-svg-22kwqxhvGlwI4QeO .statediagram-note rect{fill:#fff5ad;stroke:#aa3;stroke-width:1px;rx:0;ry:0}:root{--mermaid-font-family: '"trebuchet ms", verdana, arial';--mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive}#mermaid-svg-22kwqxhvGlwI4QeO .error-icon{fill:#522}#mermaid-svg-22kwqxhvGlwI4QeO .error-text{fill:#522;stroke:#522}#mermaid-svg-22kwqxhvGlwI4QeO .edge-thickness-normal{stroke-width:2px}#mermaid-svg-22kwqxhvGlwI4QeO .edge-thickness-thick{stroke-width:3.5px}#mermaid-svg-22kwqxhvGlwI4QeO .edge-pattern-solid{stroke-dasharray:0}#mermaid-svg-22kwqxhvGlwI4QeO .edge-pattern-dashed{stroke-dasharray:3}#mermaid-svg-22kwqxhvGlwI4QeO .edge-pattern-dotted{stroke-dasharray:2}#mermaid-svg-22kwqxhvGlwI4QeO .marker{fill:#333}#mermaid-svg-22kwqxhvGlwI4QeO .marker.cross{stroke:#333}:root { --mermaid-font-family: "trebuchet ms", verdana, arial;}#mermaid-svg-22kwqxhvGlwI4QeO {color: rgba(0, 0, 0, 0.75);font: ;}

dev
master
创建新分支 dev
G
F
B
E
D
C
A

讨论小剧场 01 ~
————
同学A:使用 git merge 就能解决这个问题。
小明:但提交记录会很乱,而且若之后要回滚这部分的代码还得考虑是否混杂涉及了别人的提交。
————
同学B:若只复制一两个提交到其他分支,建议使用更简单的命令 git cherry-pick
小明:没错!不过我的提交很多,还有没有其他方法呢?
————
同学C:别犹豫小伙!git rebase 欢迎你~
小明:对!就是它!

执行 git rebase master 之后,如图所示:

#mermaid-svg-ANgfYi90opRyoSBe .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-ANgfYi90opRyoSBe .label text{fill:#333}#mermaid-svg-ANgfYi90opRyoSBe .node rect,#mermaid-svg-ANgfYi90opRyoSBe .node circle,#mermaid-svg-ANgfYi90opRyoSBe .node ellipse,#mermaid-svg-ANgfYi90opRyoSBe .node polygon,#mermaid-svg-ANgfYi90opRyoSBe .node path{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-ANgfYi90opRyoSBe .node .label{text-align:center;fill:#333}#mermaid-svg-ANgfYi90opRyoSBe .node.clickable{cursor:pointer}#mermaid-svg-ANgfYi90opRyoSBe .arrowheadPath{fill:#333}#mermaid-svg-ANgfYi90opRyoSBe .edgePath .path{stroke:#333;stroke-width:1.5px}#mermaid-svg-ANgfYi90opRyoSBe .flowchart-link{stroke:#333;fill:none}#mermaid-svg-ANgfYi90opRyoSBe .edgeLabel{background-color:#e8e8e8;text-align:center}#mermaid-svg-ANgfYi90opRyoSBe .edgeLabel rect{opacity:0.9}#mermaid-svg-ANgfYi90opRyoSBe .edgeLabel span{color:#333}#mermaid-svg-ANgfYi90opRyoSBe .cluster rect{fill:#ffffde;stroke:#aa3;stroke-width:1px}#mermaid-svg-ANgfYi90opRyoSBe .cluster text{fill:#333}#mermaid-svg-ANgfYi90opRyoSBe div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:12px;background:#ffffde;border:1px solid #aa3;border-radius:2px;pointer-events:none;z-index:100}#mermaid-svg-ANgfYi90opRyoSBe .actor{stroke:#ccf;fill:#ECECFF}#mermaid-svg-ANgfYi90opRyoSBe text.actor>tspan{fill:#000;stroke:none}#mermaid-svg-ANgfYi90opRyoSBe .actor-line{stroke:grey}#mermaid-svg-ANgfYi90opRyoSBe .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333}#mermaid-svg-ANgfYi90opRyoSBe .messageLine1{stroke-width:1.5;stroke-dasharray:2, 2;stroke:#333}#mermaid-svg-ANgfYi90opRyoSBe #arrowhead path{fill:#333;stroke:#333}#mermaid-svg-ANgfYi90opRyoSBe .sequenceNumber{fill:#fff}#mermaid-svg-ANgfYi90opRyoSBe #sequencenumber{fill:#333}#mermaid-svg-ANgfYi90opRyoSBe #crosshead path{fill:#333;stroke:#333}#mermaid-svg-ANgfYi90opRyoSBe .messageText{fill:#333;stroke:#333}#mermaid-svg-ANgfYi90opRyoSBe .labelBox{stroke:#ccf;fill:#ECECFF}#mermaid-svg-ANgfYi90opRyoSBe .labelText,#mermaid-svg-ANgfYi90opRyoSBe .labelText>tspan{fill:#000;stroke:none}#mermaid-svg-ANgfYi90opRyoSBe .loopText,#mermaid-svg-ANgfYi90opRyoSBe .loopText>tspan{fill:#000;stroke:none}#mermaid-svg-ANgfYi90opRyoSBe .loopLine{stroke-width:2px;stroke-dasharray:2, 2;stroke:#ccf;fill:#ccf}#mermaid-svg-ANgfYi90opRyoSBe .note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-ANgfYi90opRyoSBe .noteText,#mermaid-svg-ANgfYi90opRyoSBe .noteText>tspan{fill:#000;stroke:none}#mermaid-svg-ANgfYi90opRyoSBe .activation0{fill:#f4f4f4;stroke:#666}#mermaid-svg-ANgfYi90opRyoSBe .activation1{fill:#f4f4f4;stroke:#666}#mermaid-svg-ANgfYi90opRyoSBe .activation2{fill:#f4f4f4;stroke:#666}#mermaid-svg-ANgfYi90opRyoSBe .mermaid-main-font{font-family:"trebuchet ms", verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ANgfYi90opRyoSBe .section{stroke:none;opacity:0.2}#mermaid-svg-ANgfYi90opRyoSBe .section0{fill:rgba(102,102,255,0.49)}#mermaid-svg-ANgfYi90opRyoSBe .section2{fill:#fff400}#mermaid-svg-ANgfYi90opRyoSBe .section1,#mermaid-svg-ANgfYi90opRyoSBe .section3{fill:#fff;opacity:0.2}#mermaid-svg-ANgfYi90opRyoSBe .sectionTitle0{fill:#333}#mermaid-svg-ANgfYi90opRyoSBe .sectionTitle1{fill:#333}#mermaid-svg-ANgfYi90opRyoSBe .sectionTitle2{fill:#333}#mermaid-svg-ANgfYi90opRyoSBe .sectionTitle3{fill:#333}#mermaid-svg-ANgfYi90opRyoSBe .sectionTitle{text-anchor:start;font-size:11px;text-height:14px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ANgfYi90opRyoSBe .grid .tick{stroke:#d3d3d3;opacity:0.8;shape-rendering:crispEdges}#mermaid-svg-ANgfYi90opRyoSBe .grid .tick text{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ANgfYi90opRyoSBe .grid path{stroke-width:0}#mermaid-svg-ANgfYi90opRyoSBe .today{fill:none;stroke:red;stroke-width:2px}#mermaid-svg-ANgfYi90opRyoSBe .task{stroke-width:2}#mermaid-svg-ANgfYi90opRyoSBe .taskText{text-anchor:middle;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ANgfYi90opRyoSBe .taskText:not([font-size]){font-size:11px}#mermaid-svg-ANgfYi90opRyoSBe .taskTextOutsideRight{fill:#000;text-anchor:start;font-size:11px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ANgfYi90opRyoSBe .taskTextOutsideLeft{fill:#000;text-anchor:end;font-size:11px}#mermaid-svg-ANgfYi90opRyoSBe .task.clickable{cursor:pointer}#mermaid-svg-ANgfYi90opRyoSBe .taskText.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-ANgfYi90opRyoSBe .taskTextOutsideLeft.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-ANgfYi90opRyoSBe .taskTextOutsideRight.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-ANgfYi90opRyoSBe .taskText0,#mermaid-svg-ANgfYi90opRyoSBe .taskText1,#mermaid-svg-ANgfYi90opRyoSBe .taskText2,#mermaid-svg-ANgfYi90opRyoSBe .taskText3{fill:#fff}#mermaid-svg-ANgfYi90opRyoSBe .task0,#mermaid-svg-ANgfYi90opRyoSBe .task1,#mermaid-svg-ANgfYi90opRyoSBe .task2,#mermaid-svg-ANgfYi90opRyoSBe .task3{fill:#8a90dd;stroke:#534fbc}#mermaid-svg-ANgfYi90opRyoSBe .taskTextOutside0,#mermaid-svg-ANgfYi90opRyoSBe .taskTextOutside2{fill:#000}#mermaid-svg-ANgfYi90opRyoSBe .taskTextOutside1,#mermaid-svg-ANgfYi90opRyoSBe .taskTextOutside3{fill:#000}#mermaid-svg-ANgfYi90opRyoSBe .active0,#mermaid-svg-ANgfYi90opRyoSBe .active1,#mermaid-svg-ANgfYi90opRyoSBe .active2,#mermaid-svg-ANgfYi90opRyoSBe .active3{fill:#bfc7ff;stroke:#534fbc}#mermaid-svg-ANgfYi90opRyoSBe .activeText0,#mermaid-svg-ANgfYi90opRyoSBe .activeText1,#mermaid-svg-ANgfYi90opRyoSBe .activeText2,#mermaid-svg-ANgfYi90opRyoSBe .activeText3{fill:#000 !important}#mermaid-svg-ANgfYi90opRyoSBe .done0,#mermaid-svg-ANgfYi90opRyoSBe .done1,#mermaid-svg-ANgfYi90opRyoSBe .done2,#mermaid-svg-ANgfYi90opRyoSBe .done3{stroke:grey;fill:#d3d3d3;stroke-width:2}#mermaid-svg-ANgfYi90opRyoSBe .doneText0,#mermaid-svg-ANgfYi90opRyoSBe .doneText1,#mermaid-svg-ANgfYi90opRyoSBe .doneText2,#mermaid-svg-ANgfYi90opRyoSBe .doneText3{fill:#000 !important}#mermaid-svg-ANgfYi90opRyoSBe .crit0,#mermaid-svg-ANgfYi90opRyoSBe .crit1,#mermaid-svg-ANgfYi90opRyoSBe .crit2,#mermaid-svg-ANgfYi90opRyoSBe .crit3{stroke:#f88;fill:red;stroke-width:2}#mermaid-svg-ANgfYi90opRyoSBe .activeCrit0,#mermaid-svg-ANgfYi90opRyoSBe .activeCrit1,#mermaid-svg-ANgfYi90opRyoSBe .activeCrit2,#mermaid-svg-ANgfYi90opRyoSBe .activeCrit3{stroke:#f88;fill:#bfc7ff;stroke-width:2}#mermaid-svg-ANgfYi90opRyoSBe .doneCrit0,#mermaid-svg-ANgfYi90opRyoSBe .doneCrit1,#mermaid-svg-ANgfYi90opRyoSBe .doneCrit2,#mermaid-svg-ANgfYi90opRyoSBe .doneCrit3{stroke:#f88;fill:#d3d3d3;stroke-width:2;cursor:pointer;shape-rendering:crispEdges}#mermaid-svg-ANgfYi90opRyoSBe .milestone{transform:rotate(45deg) scale(0.8, 0.8)}#mermaid-svg-ANgfYi90opRyoSBe .milestoneText{font-style:italic}#mermaid-svg-ANgfYi90opRyoSBe .doneCritText0,#mermaid-svg-ANgfYi90opRyoSBe .doneCritText1,#mermaid-svg-ANgfYi90opRyoSBe .doneCritText2,#mermaid-svg-ANgfYi90opRyoSBe .doneCritText3{fill:#000 !important}#mermaid-svg-ANgfYi90opRyoSBe .activeCritText0,#mermaid-svg-ANgfYi90opRyoSBe .activeCritText1,#mermaid-svg-ANgfYi90opRyoSBe .activeCritText2,#mermaid-svg-ANgfYi90opRyoSBe .activeCritText3{fill:#000 !important}#mermaid-svg-ANgfYi90opRyoSBe .titleText{text-anchor:middle;font-size:18px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ANgfYi90opRyoSBe g.classGroup text{fill:#9370db;stroke:none;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:10px}#mermaid-svg-ANgfYi90opRyoSBe g.classGroup text .title{font-weight:bolder}#mermaid-svg-ANgfYi90opRyoSBe g.clickable{cursor:pointer}#mermaid-svg-ANgfYi90opRyoSBe g.classGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-ANgfYi90opRyoSBe g.classGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-ANgfYi90opRyoSBe .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5}#mermaid-svg-ANgfYi90opRyoSBe .classLabel .label{fill:#9370db;font-size:10px}#mermaid-svg-ANgfYi90opRyoSBe .relation{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-ANgfYi90opRyoSBe .dashed-line{stroke-dasharray:3}#mermaid-svg-ANgfYi90opRyoSBe #compositionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-ANgfYi90opRyoSBe #compositionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-ANgfYi90opRyoSBe #aggregationStart{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-ANgfYi90opRyoSBe #aggregationEnd{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-ANgfYi90opRyoSBe #dependencyStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-ANgfYi90opRyoSBe #dependencyEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-ANgfYi90opRyoSBe #extensionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-ANgfYi90opRyoSBe #extensionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-ANgfYi90opRyoSBe .commit-id,#mermaid-svg-ANgfYi90opRyoSBe .commit-msg,#mermaid-svg-ANgfYi90opRyoSBe .branch-label{fill:lightgrey;color:lightgrey;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ANgfYi90opRyoSBe .pieTitleText{text-anchor:middle;font-size:25px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ANgfYi90opRyoSBe .slice{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ANgfYi90opRyoSBe g.stateGroup text{fill:#9370db;stroke:none;font-size:10px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ANgfYi90opRyoSBe g.stateGroup text{fill:#9370db;fill:#333;stroke:none;font-size:10px}#mermaid-svg-ANgfYi90opRyoSBe g.statediagram-cluster .cluster-label text{fill:#333}#mermaid-svg-ANgfYi90opRyoSBe g.stateGroup .state-title{font-weight:bolder;fill:#000}#mermaid-svg-ANgfYi90opRyoSBe g.stateGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-ANgfYi90opRyoSBe g.stateGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-ANgfYi90opRyoSBe .transition{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-ANgfYi90opRyoSBe .stateGroup .composit{fill:white;border-bottom:1px}#mermaid-svg-ANgfYi90opRyoSBe .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px}#mermaid-svg-ANgfYi90opRyoSBe .state-note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-ANgfYi90opRyoSBe .state-note text{fill:black;stroke:none;font-size:10px}#mermaid-svg-ANgfYi90opRyoSBe .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.7}#mermaid-svg-ANgfYi90opRyoSBe .edgeLabel text{fill:#333}#mermaid-svg-ANgfYi90opRyoSBe .stateLabel text{fill:#000;font-size:10px;font-weight:bold;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-ANgfYi90opRyoSBe .node circle.state-start{fill:black;stroke:black}#mermaid-svg-ANgfYi90opRyoSBe .node circle.state-end{fill:black;stroke:white;stroke-width:1.5}#mermaid-svg-ANgfYi90opRyoSBe #statediagram-barbEnd{fill:#9370db}#mermaid-svg-ANgfYi90opRyoSBe .statediagram-cluster rect{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-ANgfYi90opRyoSBe .statediagram-cluster rect.outer{rx:5px;ry:5px}#mermaid-svg-ANgfYi90opRyoSBe .statediagram-state .divider{stroke:#9370db}#mermaid-svg-ANgfYi90opRyoSBe .statediagram-state .title-state{rx:5px;ry:5px}#mermaid-svg-ANgfYi90opRyoSBe .statediagram-cluster.statediagram-cluster .inner{fill:white}#mermaid-svg-ANgfYi90opRyoSBe .statediagram-cluster.statediagram-cluster-alt .inner{fill:#e0e0e0}#mermaid-svg-ANgfYi90opRyoSBe .statediagram-cluster .inner{rx:0;ry:0}#mermaid-svg-ANgfYi90opRyoSBe .statediagram-state rect.basic{rx:5px;ry:5px}#mermaid-svg-ANgfYi90opRyoSBe .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#efefef}#mermaid-svg-ANgfYi90opRyoSBe .note-edge{stroke-dasharray:5}#mermaid-svg-ANgfYi90opRyoSBe .statediagram-note rect{fill:#fff5ad;stroke:#aa3;stroke-width:1px;rx:0;ry:0}:root{--mermaid-font-family: '"trebuchet ms", verdana, arial';--mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive}#mermaid-svg-ANgfYi90opRyoSBe .error-icon{fill:#522}#mermaid-svg-ANgfYi90opRyoSBe .error-text{fill:#522;stroke:#522}#mermaid-svg-ANgfYi90opRyoSBe .edge-thickness-normal{stroke-width:2px}#mermaid-svg-ANgfYi90opRyoSBe .edge-thickness-thick{stroke-width:3.5px}#mermaid-svg-ANgfYi90opRyoSBe .edge-pattern-solid{stroke-dasharray:0}#mermaid-svg-ANgfYi90opRyoSBe .edge-pattern-dashed{stroke-dasharray:3}#mermaid-svg-ANgfYi90opRyoSBe .edge-pattern-dotted{stroke-dasharray:2}#mermaid-svg-ANgfYi90opRyoSBe .marker{fill:#333}#mermaid-svg-ANgfYi90opRyoSBe .marker.cross{stroke:#333}:root { --mermaid-font-family: "trebuchet ms", verdana, arial;}#mermaid-svg-ANgfYi90opRyoSBe {color: rgba(0, 0, 0, 0.75);font: ;}

dev
master
小明 dev 复制版
创建新分支 dev
G
F
B
E
D
C
A
F1
G1

02 应用场景

2.1 合并子分支到主分支

$ git rebase <想要同步的分支名>

情景:你从主分支 master 切出分支 dev 进行开发。在你开发的过程中,你的小伙伴将他的修改早已合到 master 中,导致你的分支 dev 落后于 master ,这时想要同步 master 的改动。

操作说明

Git 笔记 - git rebase相关推荐

  1. Git 笔记 - git pull

    git pull 命令用于从远程获取代码并合并本地的版本,即可以理解为 git pull = git fetch + git merge I)git pull <远程主机名> <远程 ...

  2. git 32位_完整的GIT笔记 快速上手小白教程

    GIT 是什么? Git 是目前世界上最先进的分布式版本控制系统.并且它是一个免费的.开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目. 什么是版本控制系统 版本控制是一种系统,它跟踪一 ...

  3. Git笔记(37) 替换

    Git笔记(37) 替换 1. 替换 2. 举例 1. 替换 之前强调过,Git 对象数据库中的对象是不可改变的 然而 Git 提供了一种有趣的方式来用其他对象 假装 替换数据库中的 Git 对象 r ...

  4. Git笔记(33) Rerere

    Git笔记(33) Rerere 1. 重用记录的解决方案 2. 干净的合并和变基 3. 举例 1. 重用记录的解决方案 git rerere 功能是一个隐藏的功能 正如它的名字"重用记录的 ...

  5. Git笔记(25) 选择修订版本

    Git笔记(25) 选择修订版本 1. 单个修订版本 1.1. 简短的 SHA-1 1.2. 分支引用 1.3. 引用日志 1.4. 祖先引用 2. 提交区间 2.1. 双点 2.2. 多点 2.3. ...

  6. Git笔记(23) 不同角色的贡献

    Git笔记(23) 不同角色的贡献 1. 私有小型团队 2. 私有管理团队 3. 派生的公开项目 4. 通过邮件的公开项目 1. 私有小型团队 可能会遇到的最简单的配置是有一两个开发者的私有(闭源)项 ...

  7. Git笔记(16) 变基

    Git笔记(16) 变基 1. 整合分支 2. 基本操作 3. 指定目标分支 4. 变基的风险 5. 用变基解决变基 6. 手动解决变基 7. 整合原则 1. 整合分支 在 Git笔记(12) 分支使 ...

  8. Git笔记(ydl)

    Git笔记(ydl) 第一章 理论基础 一 .Git安装 windows安装:进入网站https://git-scm.com/下载安装,然后在cmd命令行配置 直接去腾讯软件中心下载也可以! > ...

  9. 取得 Git 仓库 —— Git 学习笔记 04

    取得 Git 仓库 -- Git 学习笔记 04 我认为, Git 的学习分为两大块:一是工作区.索引.本地版本库之间的交互:二是本地版本库和远程版本库之间的交互.第一块是基础,第二块是难点. 下面, ...

  10. 【Git笔记1】本地项目与GitHub远程仓库互联

    秋招面试的时候,面试官就问了我:你会Git吗?我迟疑看着他,他微笑着说,入职前要抓紧时间好好学习一下. 由于地理位置优势先来公司熟悉下环境,咨询算法组组长入职前可以做些什么准备?组长说,Git要好好学 ...

最新文章

  1. seL4 microkernel学习资料
  2. 揭秘HTML5和CSS3
  3. .NET Core + Kubernetes:Volume
  4. layui结合form,table的全选、反选v1.0
  5. Telnet命令检测远程主机上的端口是否开启
  6. 服务器端事件发送SSE
  7. 面试官:说说Java对象的四种引用方式
  8. 使用tomcat+eclipse搭建javaweb基础开发环境
  9. 倾斜摄影 实景三维建模软件photoscan教程
  10. vue打印指定的html,使用window.print()打印指定的一个vue 组件
  11. xamarin android pdf,Xamarin 中的Android资源及使用.pdf
  12. 抄送列表 ,处理邮件,年会抽奖
  13. AR unity制作阴影
  14. 树莓派各版本引脚及参数
  15. 手把手带你玩转 Ubuntu,你学废了么?
  16. 审视自己也是一种进步
  17. ABBYY FineReader 14之扫描至OCR编辑器功能怎么用
  18. 网络音乐收费箭在弦上:下载付费成必然
  19. 【Unity】InputSystem
  20. Linux上屏幕录制录像软件大比较

热门文章

  1. OpenStack单节点平台搭建
  2. 20221118-数学函数图像在线工具推荐
  3. 电脑水冷,论电脑到底有没有必要装水冷
  4. 【Java】用java程序求李白的酒
  5. banner图的开发
  6. 利用STM32精确测量电压
  7. ubuntu清除dns缓存_如何在Ubuntu上清除DNS缓存
  8. 《指弹:周杰伦青花瓷》
  9. 麦克劳林公式求sin
  10. Windows10系统EFI分区和OEM分区的删除方法