<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          沖突還在用git merge嗎?互聯(lián)網(wǎng)公司都用git rebase

          共 954字,需瀏覽 2分鐘

           ·

          2021-11-14 16:52

          git merge 和 git rebase的區(qū)別

          目的都是將一個分支的commit合并到到另外一個分支中去

          git merge

          1. 在gitlab上新建一個項目,push一個test文件上去

          2.在本地修改test文件做兩次commit,每次commit都在文件中加一句修改

          3.在遠(yuǎn)程倉庫中直接修改文件并commit,模擬其他開發(fā)者的commit

          4.如果此時我push本地的提交到遠(yuǎn)程,就會被拒絕,因為遠(yuǎn)程和本地已經(jīng)各自有commit了,我們常規(guī)的做法是git pull一下,在本地解決沖突,然后繼續(xù)push,本質(zhì)上git pull = git fetch + git merge

          產(chǎn)生沖突:

          處理沖突:

          重新走add commit 然后push,可以看到必須將合并當(dāng)作一個新的commit:

          git rebase

          如果我們此時采用git pull --rebase,也就是=git fetch + git rebase

          1. 一樣本地commit2次,遠(yuǎn)程commit2次

          1. 使用可以看到git pull --rebase,還是會提示我們?nèi)ヌ幚頉_突,但是從git log 上可以看出明顯已經(jīng)發(fā)生了rebase,也就是變基,本地分支基于了遠(yuǎn)程的最新commit,而不是上次的本地commit

          1. 處理沖突,每處理完一次本地commit沖突,用git add標(biāo)記沖突已處理完,用git rebase --continue繼續(xù)處理下一個本地commit,也可以先用git rebase -i將本地的commit合并為一個commit,這樣git pull --rebase就能一次處理所有的沖突

          1. push到遠(yuǎn)程之后,在分支圖可以明顯看到,跟merge的區(qū)別在于,rebase不會產(chǎn)生分支,并且也不會產(chǎn)生新的提交


          作者:Will_Liao
          鏈接:https://juejin.cn/post/7001409038307033119
          來源:稀土掘金
          著作權(quán)歸作者所有。商業(yè)轉(zhuǎn)載請聯(lián)系作者獲得授權(quán),非商業(yè)轉(zhuǎn)載請注明出處。



          瀏覽 43
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  色婷婷亚洲网 | 骚婷婷肏屄 | 免费麻豆国产一区二区三区四区 | 日韩在线无 | 中国一级操逼视频 |