<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                [TOC] ## 概述 有兩個常用功能 ### 合并分支 - 用于把一個分支的修改合并到當前分支 - 執行merge之后,會產生一個新的commit,如:Merge branch 'branch-1', 使用rebase的話就會避免這個問題 **原理**: 1. 這些命令會把你的”mywork“分支里的每個提交(commit)取消掉, 2. 并且把它們臨時 保存為補丁(patch)(這些補丁放到”.git/rebase“目錄中), 3. 然后把”mywork“分支更新 到最新的”origin“分支, 4. 最后把保存的這些補丁應用到”mywork“分支上 ### 當分支的歷史 commit 對當前分支的歷史commit進行修改,合并,刪除等操作 ## 語法 ``` git rebase [-i | --interactive] [options] [--exec <cmd>] [--onto <newbase>] [<upstream> [<branch>]] git rebase [-i | --interactive] [options] [--exec <cmd>] [--onto <newbase>] --root [<branch>] git rebase --continue | --skip | --abort | --quit | --edit-todo rebase 動作說明: pick:保留該commit(縮寫:p) reword:保留該commit,但我需要修改該commit的注釋(縮寫:r) edit:保留該commit, 但我要停下來修改該提交(不僅僅修改注釋)(縮寫:e) squash:將該commit和前一個commit合并(縮寫:s) fixup:將該commit和前一個commit合并,但我不要保留該提交的注釋信息(縮寫:f) exec:執行shell命令(縮寫:x) drop:我要丟棄該commit(縮寫:d) 注意區間為前開后閉的區間,不包含[startpoint],包含[endpoint] ``` ### 解決沖突并繼續 `rebase --continue` 1. `git rebase`出現沖突并停止 2. 解決沖突并`git add` 3. `git rebase --continue`提交而不是commit ### 沖突時取消rebase `rebase --abort` - 可以用`--abort`參數來終止`rebase`的操作,并且”`mywork`“ 分支會回到`rebase`開始前的狀態 ``` git rebase --abort ``` ## 場景 ### 移除一個提交 語法 ``` git rebase -i [startpoint] [endpoint] //or git rebase -i HEAD~3 ``` ![](https://pic4.zhimg.com/v2-7189da3226d1fdedeb6a297fbc2b1177_b.webp) ### 合并多個commit為一 語法 ``` // 注意如果 [endpoint]不寫,則默認到最新 // 如果添加 [endpoint] 則會產生游離的 HEAD git rebase -i [startpoint] [endpoint] //or git rebase -i HEAD~3 // 推送到遠程分支,使用 --force 或 --force-with-lease, // 只對對應的遠程分分支有作用,不用擔心覆蓋其他分支 git push --force-with-lease ``` ![](https://pic3.zhimg.com/v2-758ead2cd3914cadc4d822053ad1089a_b.webp) ### 合并中間的多個comit 需要從想要合并的最早分支開始 ,到最新未知,并對中間的commit 進行修改 ### 多個commit粘貼到另一個分支上 ![](https://img.kancloud.cn/48/39/4839cc8bb557c7c80bfc497a9f52ce91_500x204.jpg) 語法 ``` > git rebase [startpoint] [endpoint] --onto [branchName] 說明 startpoint endpoint 指定了一個編輯版本區間(前開后閉) --onto 該指定的提交復制到哪個分支上 ``` 實例 ``` > git rebase 90bc0045b^ 5de0da9f2 --onto master // 當前HEAD處于游離狀態 > git checkout master > git log //查看游離的人 版本信息 > git reset --hard 0c72e64 ``` ### 開發分支與主分支的管理 1. 在最新的主分支創建分支 ``` git checkout -b dev ``` 2. 完成分支任務,commit 3. 進行rebase,選擇的目標為主分支 ``` git rebase master ``` 4. 可以進行 `merge request` 或 `pull request`,在代碼審計中,不斷修復,需要不斷 rebase 5. 合并到主分支 ``` git checkout master git merge dev ``` ![](https://pic2.zhimg.com/v2-6b8427b4baf6cdfb08b852ab1cdb4941_b.webp) > 值得注意的是合并前必須使用 當前最新主分支 rebase 上,這樣在合并過去就不會使主分支歷史記錄變得簡潔
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看