1fy07h 发表于 2024-10-3 05:29:08

Git 分支管理全攻略:一篇博客带你玩转代码分支!


    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">什么是分支?在 Git 里,分支其实就有点像一个树的枝杈,<span style="color: black;">每一个</span>分支上<span style="color: black;">能够</span>有<span style="color: black;">区别</span>的文件的版本,并且不会互相干扰。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/sz_mmbiz_png/PdyWzr1ic1ajyUicW8Jygem8MtBplLwC0ATUgYZACic4ibHOVoiaRw0HvrqtwibiaFEwIS34wFZ6r1UPT2j634uzw56fg/640?wx_fmt=png&amp;from=appmsg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">分支功能有什么用?在工作中,<span style="color: black;">咱们</span>经常是需要和别人<span style="color: black;">一块</span><span style="color: black;">研发</span>一个项目的,此时可能你<span style="color: black;">研发</span> A 功能,别人<span style="color: black;">研发</span> B 功能;<span style="color: black;">倘若</span><span style="color: black;">仅有</span>一个分支的话,<span style="color: black;">那样</span>所有人都得在这个分支上干活;<span style="color: black;">倘若</span>你<span style="color: black;">研发</span>完了功能,但是别人<span style="color: black;">无</span><span style="color: black;">研发</span>完,<span style="color: black;">那样</span>还得等其他人<span style="color: black;">研发</span>完(<span style="color: black;">否则</span><span style="color: black;">研发</span>到一半的功能,怎么给别人<span style="color: black;">运用</span>,是吧)。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">此刻</span>有了分支,完全<span style="color: black;">能够</span>创建多个分支,想提交就提交,<span style="color: black;">研发</span>完后再合并到原来的分支上,<span style="color: black;">这般</span>就不会影响(<span style="color: black;">或</span>被影响)别人工作。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">其他版本<span style="color: black;">掌控</span>系统如 SVN 等都有分支管理,<span style="color: black;">然则</span>用过之后你会<span style="color: black;">发掘</span>,这些版本<span style="color: black;">掌控</span>系统创建和切换分支比蜗牛还慢,简直让人<span style="color: black;">没法</span>忍受,结果分支功能<span style="color: black;">成为了</span><span style="color: black;">安排</span>,<span style="color: black;">大众</span>都不去用。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">但 Git 的分支是与众<span style="color: black;">区别</span>的,无论创建、切换和删除分支,Git 在 1 秒钟之内就能完成!无论你的版本库是 1 个文件还是 1 万个文件。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <h2 style="color: black; text-align: left; margin-bottom: 10px;">图示分支的概念</h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">咱们</span>之前说过,每提交一个新版本,Git 就会把它们自动串成一条时间线,这条时间线<span style="color: black;">便是</span>一个分支。截止到<span style="color: black;">日前</span>,<span style="color: black;">仅有</span>一条时间线,在 Git 里,这个分支叫主分支,即 master 分支。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">一<span style="color: black;">起始</span>的时候,master 分支是一条线,Git 用 master 指向最新的提交,再用 HEAD 指向 master,就能确定当前分支,以及当前分支的提交点:</p><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> HEAD</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ▼</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> master</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">▼</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">┌───┐ ┌───┐ ┌───┐</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">│ │───→│ │───→│ │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">└───┘ └───┘ └───┘</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">当<span style="color: black;">咱们</span>创建新的分支,例如 dev 时,Git 新建了一个指针叫 dev,指向 master 相同的提交,再把 HEAD 指向 dev,就<span style="color: black;">暗示</span>当前分支在 dev 上:</p><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> master</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ▼</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">┌───┐ ┌───┐ ┌───┐</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">│ │───→│ │───→│ │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">└───┘ └───┘ └───┘</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ▲</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> dev</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ▲</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> HEAD</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Git 创建一个分支<span style="color: black;">火速</span>,<span style="color: black;">由于</span>除了<span style="color: black;">增多</span>一个 dev 指针,改改 HEAD 的指向,工作区的文件都<span style="color: black;">无</span>任何变化!</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">从<span style="color: black;">此刻</span><span style="color: black;">起始</span>,对工作区的修改和提交<span style="color: black;">便是</span>针对 dev 分支了,<span style="color: black;">例如</span>新提交一次后,dev 指针往前移动一步,而 master 指针不变:</p><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> master</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ▼</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">┌───┐ ┌───┐ ┌───┐ ┌───┐</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">│ │───→│ │───→│ │───→│ │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">└───┘ └───┘ └───┘ └───┘</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ▲</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> dev</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ▲</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> HEAD</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">假如<span style="color: black;">咱们</span>在 dev 上的工作完<span style="color: black;">成为了</span>,就<span style="color: black;">能够</span>把 dev 合并到 master 上。Git 怎么合并呢?最简单的<span style="color: black;">办法</span>,<span style="color: black;">便是</span>直接把 master 指向 dev 的当前提交,就完<span style="color: black;">成为了</span>合并:</p><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> HEAD</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ▼</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> master</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ▼</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">┌───┐ ┌───┐ ┌───┐ ┌───┐</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">│ │───→│ │───→│ │───→│ │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">└───┘ └───┘ └───┘ └───┘</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ▲</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">│</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> dev</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">因此</span> Git 合并分支<span style="color: black;">亦</span><span style="color: black;">火速</span>!就改改指针,工作区内容<span style="color: black;">亦</span>不变!</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">合并完分支后,<span style="color: black;">乃至</span><span style="color: black;">能够</span>删除 dev 分支。删除 dev 分支<span style="color: black;">便是</span>把 dev 指针给删掉,删掉后,<span style="color: black;">咱们</span>就剩下了一条 master 分支:</p><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> HEAD</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ▼</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> master</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ▼</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">┌───┐ ┌───┐ ┌───┐ ┌───┐</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">│ │───→│ │───→│ │───→│ │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">└───┘ └───┘ └───┘ └───┘</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">在<span style="color: black;">实质</span><span style="color: black;">研发</span>中,<span style="color: black;">咱们</span>应该<span style="color: black;">根据</span>几个基本原则进行分支管理:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">master 分支应该是非常稳定的,用作主分支(就像一棵树总得有个树干,<span style="color: black;">不可</span>光有树枝),<span style="color: black;">亦</span><span style="color: black;">便是</span>仅用来发布新版本,平时<span style="color: black;">不可</span>在上面干活;</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">干活都在 dev 分支上,<span style="color: black;">亦</span><span style="color: black;">便是</span>说,dev 分支是不稳定的,到某个时候,<span style="color: black;">例如</span> 1.0 版本<span style="color: black;">研发</span>完并测试完了,准备发布时,再把 dev 分支合并到 master 上</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">你和你的小伙伴们<span style="color: black;">每一个</span>人都有自己的分支,时不时地往 dev 分支上合并就<span style="color: black;">能够</span>了。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">因此</span>,团队合作的分支看起来就像<span style="color: black;">这般</span>:</p><img src="https://mmbiz.qpic.cn/sz_mmbiz_png/PdyWzr1ic1ajyUicW8Jygem8MtBplLwC0A6M68HCr0vTJribWP155efQrhWRPyVQay5iaZuZib4NnyDeaabJnrUMVcw/640?wx_fmt=png&amp;from=appmsg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;">git-br-policy<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <h2 style="color: black; text-align: left; margin-bottom: 10px;">创建分支</h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">请读者务必<span style="color: black;">亦</span>动手实践!</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">咱们</span><span style="color: black;">运用</span> git branch 分支名 来创建分支:</p><span style="color: black;">$ <span style="color: black;">git</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> branch dev</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">咱们</span><span style="color: black;">能够</span><span style="color: black;">运用</span> git branch 来查看当前分支的创建<span style="color: black;">状况</span>:</p><span style="color: black;">$ <span style="color: black;">git</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> branch</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> dev</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">* master</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">git branch 命令会列出所有分支,当前分支前面会标一个 * 号,<span style="color: black;">能够</span>看到<span style="color: black;">此刻</span>有两个分支,一个是 dev,一个是 master。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">而后</span><span style="color: black;">咱们</span>就<span style="color: black;">能够</span>用 git switch 分支名 切换分支了:</p><span style="color: black;">$ <span style="color: black;">git</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> switch dev</p>
    </span><span style="color: black;">Switched to branch <span style="color: black;">dev</span></span><span style="color: black;">$ <span style="color: black;">git</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> branch</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">* dev</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> master</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">亦</span><span style="color: black;">能够</span>一条命令创建并切换分支:</p><span style="color: black;">$ <span style="color: black;">git</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> switch -c dev</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">倘若</span>需要频繁切换分支,<span style="color: black;">能够</span>简写:</p><span style="color: black;">$ <span style="color: black;">git</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> switch -</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <h2 style="color: black; text-align: left; margin-bottom: 10px;">管理分支</h2>
    <h3 style="color: black; text-align: left; margin-bottom: 10px;">删除分支</h3>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">倘若</span><span style="color: black;">咱们</span>要删除分支,<span style="color: black;">运用</span> git branch -d 分支名 <span style="color: black;">就可</span>。<span style="color: black;">重视</span>,<span style="color: black;">不可</span>删除当前分支。例如<span style="color: black;">咱们</span>当前在 dev 分支,<span style="color: black;">倘若</span>删除就<span style="color: black;">报答</span>错:</p><span style="color: black;">$ <span style="color: black;">git</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> branch -d dev</p>
    </span><span style="color: black;">error: Cannot delete branch <span style="color: black;">dev</span>checked out at<span style="color: black;">D:/Projects/LearnGit</span></span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">得切换到其他分支后,<span style="color: black;">才可</span>删除</p><span style="color: black;">$ <span style="color: black;">git</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> switch master</p>
    </span><span style="color: black;">Switched to branch <span style="color: black;">master</span></span><span style="color: black;">Your branch is ahead of <span style="color: black;">gitee/master</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> by 8 commits.</p>
    </span><span style="color: black;"> <span style="color: black;">(</span>use <span style="color: black;">"git push"</span>to publish your<span style="color: black;">local</span> commits<span style="color: black;">)</span></span><span style="color: black;">$ <span style="color: black;">git</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> branch -d dev</p>
    </span><span style="color: black;">Deleted branch dev <span style="color: black;">(</span>was 0066f6d<span style="color: black;">)</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">.</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <h3 style="color: black; text-align: left; margin-bottom: 10px;">查看分支创建时间</h3>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">git reflog show --date=iso &lt;branch name&gt; 命令<span style="color: black;">能够</span>查看到指定分支的历次更改记录,最下面一条的时间即是分支创建时间。</p><span style="color: black;">$ <span style="color: black;">git</span> reflog show --date<span style="color: black;">=</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">iso dev</p>
    </span><span style="color: black;">0066f6d <span style="color: black;">(</span>HEAD -<span style="color: black;">&gt;</span> dev, master<span style="color: black;">)</span> dev@<span style="color: black;">{</span>2023-01-14 15:40:45 +0800<span style="color: black;">}</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">: branch: Created from HEAD</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <h3 style="color: black; text-align: left; margin-bottom: 10px;">重命名分支</h3>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">有时候<span style="color: black;">发掘</span>创建的分支名字搞错了,要改名,怎么办?<span style="color: black;">运用</span>如下命令:</p><span style="color: black;">$ <span style="color: black;">git</span> branch -m <span style="color: black;">&lt;</span>old_branch_name<span style="color: black;">&gt;</span> <span style="color: black;">&lt;</span>new_branch_name<span style="color: black;">&gt;</span></span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">当你要重命名的分支恰好是当前分支时,就不需要指定旧的分支名<span style="color: black;">叫作</span>。</p><span style="color: black;">$ <span style="color: black;">git</span> branch -m <span style="color: black;">&lt;</span>new_branch_name<span style="color: black;">&gt;</span></span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <h3 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">查找</span>分支</h3>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">之前<span style="color: black;">咱们</span>说了查看本地分支<span style="color: black;">能够</span>:</p><span style="color: black;">$ <span style="color: black;">git</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> branch</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> bug</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">feature</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">* master</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">倘若</span>要列出所有分支(本地和远程),假设 -a 参数:</p><span style="color: black;">$ <span style="color: black;">git</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> branch -a</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> bug</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> feature</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">* master</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> remotes/gitee/feature</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> remotes/gitee/master</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> remotes/github/feature</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">remotes/github/master</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <h2 style="color: black; text-align: left; margin-bottom: 10px;">合并分支</h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">接下来<span style="color: black;">咱们</span>演示下,在其他分支上编写代码,<span style="color: black;">而后</span>合并到 master 分支。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">首要</span>还是得创建分支</p><span style="color: black;">$ <span style="color: black;">git</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> switch -c dev</p>
    </span><span style="color: black;">Switched to a new branch <span style="color: black;">dev</span></span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">咱们</span>创建一个新的文件夹,用来存放<span style="color: black;">咱们</span>演示的文件。</p><span style="color: black;">$ <span style="color: black;">mkdir</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 3-branch</p>
    </span><span style="color: black;">$ <span style="color: black;">echo</span> <span style="color: black;">"Creating a new branch is quick"</span> <span style="color: black;">&gt;</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 3-branch/branch.txt</p>
    </span><span style="color: black;">$ <span style="color: black;">git</span> <span style="color: black;">add</span> <span style="color: black;">.</span></span><span style="color: black;">$ <span style="color: black;">git</span> commit -m <span style="color: black;">"branch test"</span></span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">此刻</span>,dev 分支的工作完成,<span style="color: black;">咱们</span>就<span style="color: black;">能够</span>切换回 master 分支:</p><span style="color: black;">$ <span style="color: black;">git</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> checkout master</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">切换回 master 分支后,<span style="color: black;">咱们</span><span style="color: black;">能够</span>看到<span style="color: black;">刚才</span>创建的文件夹不见了:</p><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$ ll</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">total 5</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">drwxr-xr-x 1 peterjxl 197121 0 1月 11 07:37 1-diffAndPath/</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">drwxr-xr-x 1 peterjxl 197121 0 1月 14 07:19 2-versionControl/</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">-rw-r--r-- 1 peterjxl 197121 33 1月 13 22:53 readme.md</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">由于</span>那个提交是在 dev 分支上,而 master 分支此刻的提交点并<span style="color: black;">无</span>变:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/sz_mmbiz_png/PdyWzr1ic1ajyUicW8Jygem8MtBplLwC0AmRsia3ticU39hLaGoxicK662icXibDJZF8ic0NTSMovnD8Fickv4crtfZ80NQ/640?wx_fmt=png&amp;from=appmsg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">此刻</span>,<span style="color: black;">咱们</span>来合并分支:</p><span style="color: black;">$ <span style="color: black;">git</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> merge dev</p>
    </span><span style="color: black;">Updating 0066f6d<span style="color: black;">..</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">5a512b7</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Fast-forward</p>
    </span><span style="color: black;"> 3-branch/branch.txt <span style="color: black;">|</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 1 +</p>
    </span><span style="color: black;"> 1 <span style="color: black;">file</span> changed, 1 insertion<span style="color: black;">(</span>+<span style="color: black;">)</span></span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> create mode 100644 3-branch/branch.txt</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">重视</span> Git 的提示:Fast-forward,指的是<span style="color: black;">这次</span>合并是“快进模式”,<span style="color: black;">亦</span><span style="color: black;">便是</span>直接把 master 指向 dev 的当前提交,<span style="color: black;">因此</span>合并速度非常快。当然,<span style="color: black;">亦</span>不是每次合并都能 Fast-forward,<span style="color: black;">咱们</span>后面会讲其他方式的合并。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">能够</span>看到<span style="color: black;">此刻</span> master 分支上,<span style="color: black;">已然</span> dev 分支<span style="color: black;">研发</span>的内容了:</p><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$ ll</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">total 5</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">drwxr-xr-x 1 peterjxl 197121 0 1月 11 07:37 1-diffAndPath/</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">drwxr-xr-x 1 peterjxl 197121 0 1月 14 07:19 2-versionControl/</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">drwxr-xr-x 1 peterjxl 197121 0 1月 14 15:54 3-branch/</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">-rw-r--r-- 1 peterjxl 197121 33 1月 13 22:53 readme.md</p>
    </span><span style="color: black;">$ <span style="color: black;">cat</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 3-branch/branch.txt</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Creating a new branch is quick</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">倘若</span>要丢弃一个<span style="color: black;">无</span>被合并过的分支,<span style="color: black;">能够</span><span style="color: black;">经过</span> git branch -D &lt;name&gt; 强行删除,否则会报错:</p><span style="color: black;">$ <span style="color: black;">git</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">branch -d feature-vulcan</p>
    </span><span style="color: black;">error: The branch <span style="color: black;">feature-vulcan</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> is not fully merged.</p>
    </span><span style="color: black;">If you are sure you want to delete it, run <span style="color: black;">git branch -D feature-vulcan</span><span style="color: black;">.</span></span>
    <h2 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">处理</span>冲突</h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">合并分支<span style="color: black;">亦</span>不是<span style="color: black;">那样</span>一帆风顺,经常会遇到冲突:当多个人在<span style="color: black;">区别</span>分支上修改同一个文件,<span style="color: black;">这般</span>合并的时候大概率会<span style="color: black;">出现</span>冲突,<span style="color: black;">咱们</span>来实践下。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">首要</span>创建一个新的分支:</p><span style="color: black;">$ <span style="color: black;">git</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> switch -c feature1</p>
    </span><span style="color: black;">Switched to a new branch <span style="color: black;">feature1</span></span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">修改下 branch.txt 内容如下,并提交:</p><span style="color: black;">$ <span style="color: black;">vim</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3-branch/branch.txt</p>
    </span><span style="color: black;">$ <span style="color: black;">cat</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 3-branch/branch.txt</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Creating a new branch is quick And simple</p>
    </span><span style="color: black;">$ <span style="color: black;">git</span> <span style="color: black;">add</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 3-branch/branch.txt</p>
    </span><span style="color: black;">$ <span style="color: black;">git</span> commit -m <span style="color: black;">"And simple"</span></span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">切换为 master 分支,并且<span style="color: black;">一样</span>修改 branch.txt:</p><span style="color: black;">$ <span style="color: black;">git</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> switch master</p>
    </span><span style="color: black;">$ <span style="color: black;">vim</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 3-branch/branch.txt</p>
    </span><span style="color: black;">$ <span style="color: black;">cat</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 3-branch/branch.txt</p>
    </span><span style="color: black;">Creating a new branch is quick <span style="color: black;">&amp;</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> simple</p>
    </span><span style="color: black;">$ <span style="color: black;">git</span> <span style="color: black;">add</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 3-branch/branch.txt</p>
    </span><span style="color: black;">$ <span style="color: black;">git</span>commit -m<span style="color: black;">"&amp;simple"</span></span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">此刻</span>,master 分支和 feature1 分支各自都分别有新的提交,变<span style="color: black;">成为了</span><span style="color: black;">这般</span>:</p><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> HEAD</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ▼</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> master</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ▼</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ┌───┐</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ┌─→│ │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">┌───┐ ┌───┐ ┌───┐ │ └───┘</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">│ │───→│ │───→│ │──┤</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">└───┘ └───┘ └───┘ │ ┌───┐</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> └─→│ │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> └───┘</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ▲</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> feature1</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">这种<span style="color: black;">状况</span>下,Git <span style="color: black;">没法</span>执行“快速合并”,只能试图把各自的修改合并起来,但这种合并就可能会有冲突,<span style="color: black;">咱们</span>试试看:</p><span style="color: black;">$ <span style="color: black;">git</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> merge feature1</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Auto-merging 3-branch/branch.txt</p>
    </span><span style="color: black;">CONFLICT <span style="color: black;">(</span>content<span style="color: black;">)</span>: Merge conflict<span style="color: black;">in</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 3-branch/branch.txt</p>
    </span><span style="color: black;">Automatic merge failed<span style="color: black;">;</span> fix conflicts and <span style="color: black;">then</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> commit the result.</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Git 告诉<span style="color: black;">咱们</span>,branch.txt 文件存在冲突,必须手动<span style="color: black;">处理</span>冲突后再提交。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">git status <span style="color: black;">亦</span>可以告诉<span style="color: black;">咱们</span>冲突的文件:</p><span style="color: black;">$ <span style="color: black;">git</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> status</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">On branch master</p>
    </span><span style="color: black;">Your branch is ahead of <span style="color: black;">gitee/master</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> by 10 commits.</p>
    </span><span style="color: black;"> <span style="color: black;">(</span>use <span style="color: black;">"git push"</span> to publish your <span style="color: black;">local</span> commits<span style="color: black;">)</span></span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">You have unmerged paths.</p>
    </span><span style="color: black;"> <span style="color: black;">(</span>fix conflicts and run <span style="color: black;">"git commit"</span><span style="color: black;">)</span></span><span style="color: black;"> <span style="color: black;">(</span>use <span style="color: black;">"git merge --abort"</span> to abort the merge<span style="color: black;">)</span></span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Unmerged paths:</p>
    </span><span style="color: black;"> <span style="color: black;">(</span>use <span style="color: black;">"git add &lt;file&gt;..."</span> to mark resolution<span style="color: black;">)</span></span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">both modified: 3-branch/branch.txt</p>
    </span><span style="color: black;">no changes added to commit <span style="color: black;">(</span>use <span style="color: black;">"git add"</span> and/or <span style="color: black;">"git commit -a"</span><span style="color: black;">)</span></span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">咱们</span><span style="color: black;">此刻</span><span style="color: black;">瞧瞧</span> branch.txt 的内容:</p><span style="color: black;">$ <span style="color: black;">cat</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 3-branch/branch.txt</p>
    </span><span style="color: black;"><span style="color: black;">&lt;&lt;&lt;</span><span style="color: black;">&lt;&lt;&lt;</span><span style="color: black;">&lt;</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> HEAD</p>
    </span><span style="color: black;">Creating a new branch is quick<span style="color: black;">&amp;</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> simple</p>
    </span><span style="color: black;"><span style="color: black;">==</span><span style="color: black;">==</span><span style="color: black;">==</span><span style="color: black;">=</span></span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Creating a new branch is quick And simple</p>
    </span><span style="color: black;"><span style="color: black;">&gt;&gt;</span><span style="color: black;">&gt;&gt;</span><span style="color: black;">&gt;&gt;</span><span style="color: black;">&gt;</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> feature1</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Git 用 &lt;&lt;&lt;&lt;&lt;&lt;&lt;,=======,&gt;&gt;&gt;&gt;&gt;&gt;&gt; 标记出<span style="color: black;">区别</span>分支的内容。<span style="color: black;">咱们</span>修改如下后<span style="color: black;">保留</span>:</p><span style="color: black;">$ <span style="color: black;">cat</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3-branch/branch.txt</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Creating a new branch is quick and simple</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">再提交:</p><span style="color: black;">$ <span style="color: black;">git</span> <span style="color: black;">add</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 3-branch/branch.txt</p>
    </span><span style="color: black;">$ <span style="color: black;">git</span> commit -m <span style="color: black;">"conflict fixed"</span></span><span style="color: black;"><span style="color: black;">[</span>master dd140df<span style="color: black;">]</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> conflict fixed</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">此刻</span>,master 分支和 feature1 分支变<span style="color: black;">成为了</span>下图所示:</p><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> HEAD</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ▼</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> master</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ▼</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ┌───┐ ┌───┐</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ┌─→│ │───→│ │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">┌───┐ ┌───┐ ┌───┐ │ └───┘ └───┘</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">│ │───→│ │───→│ │──┤ ▲</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">└───┘ └───┘ └───┘ │ ┌───┐ │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">└─→│ │──────┘</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> └───┘</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> ▲</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> │</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> feature1</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">用带参数的 git log <span style="color: black;">亦</span><span style="color: black;">能够</span>看到分支的合并<span style="color: black;">状况</span>:</p><span style="color: black;">$ <span style="color: black;">git</span> log --graph --pretty<span style="color: black;">=</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">oneline --abbrev-commit</p>
    </span><span style="color: black;">* dd140df <span style="color: black;">(</span>HEAD -<span style="color: black;">&gt;</span> master<span style="color: black;">)</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> conflict fixed</p>
    </span><span style="color: black;"><span style="color: black;">|</span><span style="color: black;">\</span></span><span style="color: black;"><span style="color: black;">|</span>* bbf0307<span style="color: black;">(</span>feature1<span style="color: black;">)</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> And simple</p>
    </span><span style="color: black;">* <span style="color: black;">|</span> 668f226 <span style="color: black;">&amp;</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">simple</p>
    </span><span style="color: black;"><span style="color: black;">|</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">/</p>
    </span><span style="color: black;">* 5a512b7 <span style="color: black;">(</span>dev<span style="color: black;">)</span> branch <span style="color: black;">test</span></span><span style="color: black;">* 0066f6d delete test.txt by <span style="color: black;">git</span> <span style="color: black;">rm</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> --chched</p>
    </span><span style="color: black;">* 3ce9df0 <span style="color: black;">add</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> test.txt</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">* 8a6d94d delete test.txt</p>
    </span><span style="color: black;">* 42c477d <span style="color: black;">add</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> test.txt</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">* b391595 delete test.txt</p>
    </span><span style="color: black;">* 8889d50 <span style="color: black;">add</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> test.txt</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">* 643c5ef .gitignore文件不生效,重新添加</p>
    </span><span style="color: black;">* 3d04684 <span style="color: black;">add</span> gitignore <span style="color: black;">file</span></span><span style="color: black;">* 39d7f12 <span style="color: black;">(</span>github/master, gitee/master<span style="color: black;">)</span> <span style="color: black;">add</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> readme.md</p>
    </span><span style="color: black;">* aeb06f4 <span style="color: black;">git</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> tracks changes</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">* 8f5bb58 understand how stage works</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">* efc9138 append GPL word</p>
    </span><span style="color: black;">* 750360e <span style="color: black;">add</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> distributed word</p>
    </span><span style="color: black;">* 0282c44 wrote a readme<span style="color: black;">file</span></span><span style="color: black;">* 0b3cfef <span style="color: black;">add</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> world.txt and diff.txt</p>
    </span><span style="color: black;">* abf2051 <span style="color: black;">add</span> <span style="color: black;">diff</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> and patch hello.txt</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">倘若</span>你用可视化图形界面,看到的结果<span style="color: black;">亦</span>是类似的:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="data:image/svg+xml,%3C%3Fxml version=1.0 encoding=UTF-8%3F%3E%3Csvg width=1px height=1px viewBox=0 0 1 1 version=1.1 xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=none stroke-width=1 fill=none fill-rule=evenodd fill-opacity=0%3E%3Cg transform=translate(-249.000000, -126.000000) fill=%23FFFFFF%3E%3Crect x=249 y=126 width=1 height=1%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <h2 style="color: black; text-align: left; margin-bottom: 10px;">其他合并方式</h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">合并分支时,Git 会默认用 Fast forward 模式,但这种模式下,删除分支后,会丢掉分支信息。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">倘若</span>禁用了 Fast forward 模式,Git 就会在 merge 时生成一个新的 commit,<span style="color: black;">这般</span>,从分支历史上就<span style="color: black;">能够</span>看出分支信息。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">下面<span style="color: black;">咱们</span>实战一下 --no-ff 方式的 git merge。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">咱们</span>创建一个新的分支 feature02,并修改内容后提交:</p><span style="color: black;">$ git<span style="color: black;">switch</span> <span style="color: black;">-</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">c feature02</p>
    </span><span style="color: black;">Switched to a <span style="color: black;">new</span> <span style="color: black;">branch</span> <span style="color: black;">feature02</span></span><span style="color: black;">$ vim 3<span style="color: black;">-</span>branch<span style="color: black;">/</span>branch<span style="color: black;">.</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">txt</p>
    </span><span style="color: black;">$ cat 3<span style="color: black;">-</span>branch<span style="color: black;">/</span>branch<span style="color: black;">.</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">txt</p>
    </span><span style="color: black;">Creating a <span style="color: black;">new</span> <span style="color: black;">branch</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> is quick and simple</p>
    </span><span style="color: black;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">test no fast forward</p>
    </span><span style="color: black;">$ git add 3<span style="color: black;">-</span>branch<span style="color: black;">/</span>branch<span style="color: black;">.</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">txt</p>
    </span><span style="color: black;">$ git commit <span style="color: black;">-</span>m <span style="color: black;">"test"</span></span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">此刻</span>,<span style="color: black;">咱们</span>切换回 master,并合并分支:</p><span style="color: black;">$ <span style="color: black;">git</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> switch master</p>
    </span><span style="color: black;">$ <span style="color: black;">git</span> merge --no-ff -m <span style="color: black;">"merge with no-ff"</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> feature02</p>
    </span><span style="color: black;">Merge made by the<span style="color: black;">recursive</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> strategy.</p>
    </span><span style="color: black;"> 3-branch/branch.txt <span style="color: black;">|</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 1 +</p>
    </span><span style="color: black;"> 1 <span style="color: black;">file</span> changed, 1 insertion<span style="color: black;">(</span>+<span style="color: black;">)</span></span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">由于</span><span style="color: black;">这次</span>合并要创建一个新的 commit,<span style="color: black;">因此</span>加上 -m 参数,把 commit 描述写进去。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">合并后,<span style="color: black;">咱们</span>用 git log <span style="color: black;">瞧瞧</span>分支历史:</p><span style="color: black;">$ git log <span style="color: black;">--</span>graph <span style="color: black;">--</span>pretty<span style="color: black;">=</span>oneline <span style="color: black;">--</span>abbrev<span style="color: black;">-</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">commit</p>
    </span><span style="color: black;"><span style="color: black;">*</span> <span style="color: black;">f564208</span> <span style="color: black;">(</span>HEAD <span style="color: black;">-</span><span style="color: black;">&gt;</span> master<span style="color: black;">)</span> merge <span style="color: black;">with</span> no<span style="color: black;">-</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">ff</p>
    </span><span style="color: black;"><span style="color: black;">|</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">\</p>
    </span><span style="color: black;"><span style="color: black;">|</span> <span style="color: black;">*</span> 8<span style="color: black;">f87605</span> <span style="color: black;">(</span>feature02<span style="color: black;">)</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> test</p>
    </span><span style="color: black;"><span style="color: black;">|</span><span style="color: black;">/</span></span><span style="color: black;"><span style="color: black;">*</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> dd140df conflict fixed</p>
    </span><span style="color: black;"><span style="color: black;">|</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">\</p>
    </span><span style="color: black;"><span style="color: black;">|</span> <span style="color: black;">*</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">bbf0307 And simple</p>
    </span><span style="color: black;"><span style="color: black;">*</span> <span style="color: black;">|</span> 668f226 <span style="color: black;">&amp;</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">simple</p>
    </span><span style="color: black;"><span style="color: black;">|</span><span style="color: black;">/</span></span><span style="color: black;"><span style="color: black;">*</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 5a512b7 branch test</p>
    </span><span style="color: black;"><span style="color: black;">*</span> 0066f6d <span style="color: black;">delete</span> test<span style="color: black;">.</span>txt by git rm <span style="color: black;">--</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">chched</p>
    </span><span style="color: black;"><span style="color: black;">*</span> 3ce9df0 add test<span style="color: black;">.</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">txt</p>
    </span><span style="color: black;"><span style="color: black;">*</span> 8a6d94d <span style="color: black;">delete</span> test<span style="color: black;">.</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">txt</p>
    </span><span style="color: black;"><span style="color: black;">*</span> 42c477d add test<span style="color: black;">.</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">txt</p>
    </span><span style="color: black;"><span style="color: black;">*</span> b391595 <span style="color: black;">delete</span> test<span style="color: black;">.</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">txt</p>
    </span><span style="color: black;"><span style="color: black;">*</span> 8889d50 add test<span style="color: black;">.</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">txt</p>
    </span><span style="color: black;"><span style="color: black;">*</span> 643c5ef <span style="color: black;">.</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">gitignore文件不生效,重新添加</p>
    </span><span style="color: black;"><span style="color: black;">*</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 3d04684 add gitignore file</p>
    </span><span style="color: black;"><span style="color: black;">*</span> 39<span style="color: black;">d7f12</span> <span style="color: black;">(</span>github<span style="color: black;">/</span>master<span style="color: black;">,</span> gitee<span style="color: black;">/</span>master<span style="color: black;">)</span> add readme<span style="color: black;">.</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">md</p>
    </span><span style="color: black;"><span style="color: black;">*</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">aeb06f4 git tracks changes</p>
    </span><span style="color: black;"><span style="color: black;">*</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 8f5bb58 understand how stage works</p>
    </span><span style="color: black;"><span style="color: black;">*</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> efc9138 append GPL word</p>
    </span><span style="color: black;"><span style="color: black;">*</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 750360e add distributed word</p>
    </span><span style="color: black;"><span style="color: black;">*</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 0282c44 wrote a readme file</p>
    </span><span style="color: black;"><span style="color: black;">*</span>0b3cfef add world<span style="color: black;">.</span>txt and diff<span style="color: black;">.</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">txt</p>
    </span><span style="color: black;"><span style="color: black;">*</span> abf2051 add diff and patch hello<span style="color: black;">.</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">tx</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">能够</span>看到,不<span style="color: black;">运用</span> Fast forward 模式,merge 后就像<span style="color: black;">这般</span>:</p><img src="data:image/svg+xml,%3C%3Fxml version=1.0 encoding=UTF-8%3F%3E%3Csvg width=1px height=1px viewBox=0 0 1 1 version=1.1 xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=none stroke-width=1 fill=none fill-rule=evenodd fill-opacity=0%3E%3Cg transform=translate(-249.000000, -126.000000) fill=%23FFFFFF%3E%3Crect x=249 y=126 width=1 height=1%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E" style="width: 50%; margin-bottom: 20px;">git-no-ff-mode<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">或</span>用 GitExtensions 查看,结果类似:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="data:image/svg+xml,%3C%3Fxml version=1.0 encoding=UTF-8%3F%3E%3Csvg width=1px height=1px viewBox=0 0 1 1 version=1.1 xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=none stroke-width=1 fill=none fill-rule=evenodd fill-opacity=0%3E%3Cg transform=translate(-249.000000, -126.000000) fill=%23FFFFFF%3E%3Crect x=249 y=126 width=1 height=1%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">合并分支时,加上 --no-ff 参数就<span style="color: black;">能够</span>用普通模式合并,合并后的历史有分支,能看出来曾经做过合并,而 fast forward 合并就看不出来曾经做过合并。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <h2 style="color: black; text-align: left; margin-bottom: 10px;">比较分支的差异</h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">有时候<span style="color: black;">咱们</span>需要比较两个分支的差异,<span style="color: black;">能够</span><span style="color: black;">运用</span>如下命令:</p><span style="color: black;">$ <span style="color: black;">git</span>&nbsp;<span style="color: black;">diff</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">branch1 branch2 --stat &nbsp; //<span style="color: black;">表示</span>出所有有差异的文件列表</p>
    </span><span style="color: black;">$ <span style="color: black;">git</span>&nbsp;<span style="color: black;">diff</span> branch1 branch2 文件名<span style="color: black;">(</span>带路径<span style="color: black;">)</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> &nbsp; //<span style="color: black;">表示</span>指定文件的<span style="color: black;">仔细</span>差异</p>
    </span><span style="color: black;">$ <span style="color: black;">git</span>&nbsp;<span style="color: black;">diff</span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> branch1 branch2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<span style="color: black;">表示</span>出所有有差异的文件的<span style="color: black;">仔细</span>差异</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">‍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">(未完待续...)</p>




7wu1wm0 发表于 2024-10-3 22:15:40

谷歌网站排名优化 http://www.fok120.com/

nykek5i 发表于 2024-10-25 13:16:29

在遇到你之前,我对人世间是否有真正的圣人是怀疑的。

m5k1umn 发表于 2024-10-25 14:16:28

你的言辞如同繁星闪烁,点亮了我心中的夜空。

qzmjef 发表于 2024-11-2 18:52:39

论坛的成果是显著的,但我们不能因为成绩而沾沾自喜。
页: [1]
查看完整版本: Git 分支管理全攻略:一篇博客带你玩转代码分支!