VSCode 合併分支過程記錄

20200618 之前在 gitee 上建立一個倉庫,當時直接建立了 2 個分支: master 和 develop ,之後,程序員一直在 develop 分支上修改代碼,
因爲 git 不熟練,項目代碼也不熟悉,一直沒有進行分支合併

中途曾經嘗試 merge ,但是,每次看到一大堆 conflict ,就害怕而放棄

今天終於決定完整的測試一次,已然不是在實際的項目倉庫上,而是導入到另一個倉庫進行測試

以下記錄一下完整過程,以便下次實際操作室參照

任務: 將 develop 分支合併到 master 分支

1、 命令行操作

打開 terminal ,並進入到本地倉庫所在目錄

之前已經配置並 clone 好遠程倉庫
$ git clone https://gitee.com/gold-spider/atc_frontend5

  1. 查看遠程倉庫信息
    $ git remote -v
    origin https://gitee.com/gold-spider/atc_frontend5 (fetch)
    origin https://gitee.com/gold-spider/atc_frontend5 (push)

  2. 查看分支
    $ git branch

      develop
    * master
    * 
    

    可以看到,當前分支是 master

  3. 切換並 clone 分支 develop
    $ git checkout develop
    Branch ‘develop’ set up to track remote branch ‘develop’ from ‘origin’.
    Switched to a new branch ‘develop’

    $ git clone -b develop https://gitee.com/gold-spider/atc_frontend5

  4. 切換到 master 分支,準備合併
    $ git checkout master
    Switched to branch ‘master’
    Your branch is up to date with ‘origin/master’.

  5. 將 develop 分支上的代碼合併到當前 master 分支
    git merge develop
    返回信息如下:

    warning: Cannot merge binary files: src/assets/xas_chain_assets.png (HEAD vs. develop)
    warning: Cannot merge binary files: src/assets/xas.png (HEAD vs. develop)


    CONFLICT (add/add): Merge conflict in src/utils/util.js
    Auto-merging src/utils/util.js
    CONFLICT (add/add): Merge conflict in src/utils/constants.js

    Auto-merging README.md
    CONFLICT (content): Merge conflict in README.md
    CONFLICT (add/add): Merge conflict in .eslintrc.js
    Auto-merging .eslintrc.js
    Automatic merge failed; fix conflicts and then commit the result.

有大量的衝突!

2、打開 VSCode 處理衝突

  1. 在 VSCode 上打開以上倉庫目錄
    在這裏插入圖片描述
    可以看到,我們的 atc_frontend5 chanshengle 有 65 個合併變動需要處理

  2. 一次點擊打開下方變動過的文件
    在這裏插入圖片描述在代碼區,有衝突的地方都明顯的標示出來
    在這裏插入圖片描述
    並且,給出來衝突解決選項
    Accept Current Change
    Accept Coming Change
    Accept Both Changes
    Compare Changes
    Start Live Share Session

    我們這個倉庫參與人員不多,按照實際發展過程,我們應該接受 develop 分支上程序員帶來的所有變化!也就是:
    Accept Coming Change

  3. 依次重複上一步,修改所有的變動

  4. 完成後,添加 ( + ),然後提交( Commit )試試
    在這裏插入圖片描述
    彈出來提示:
    在這裏插入圖片描述

  5. 遠程查看一下是否提交上去
    在這裏插入圖片描述

  6. 測試、改錯、測試
    一次很難處理乾淨那麼多變動,所以,需要進行測試之後提交
    上圖實際上是經過以下幾輪測試之後的 push 結果

    這是一個 quasar 框架下開發的一個 Vue 單頁面程序,所以測試過程如下:(下轄操作直接在 VSCode 裏面的 Terminal 完成)

    $ npm i
    返回錯誤:

    npm ERR! file /Users/dhbm/Desktop/ATC/atc_frontend5/package.json
    npm ERR! code EJSONPARSE
    npm ERR! Merge conflict detected in your package.json.
    npm ERR! 
    npm ERR! Please resolve the package.json conflict and retry the command:
    npm ERR! 
    npm ERR! $ /usr/local/bin/node /usr/local/bin/npm i
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /Users/dhbm/.npm/_logs/2020-06-18T09_02_33_626Z-debug.log
    

    原來,剛纔漏掉了 package.json,如下圖,右邊還標示着: 9+,M ,打開文件也確實看到有 Confilct 沒有處理
    在這裏插入圖片描述

    運行一次 dev
    quasar dev
    報錯如下:

    ......
    
     error  in ./src/i18n/de/index.js
    
    Syntax Error:   SyntaxError: /Users/dhbm/Desktop/ATC/atc_frontend5/src/i18n/de/index.js: Unexpected token (307:0)
    

    打開這個 index.js ,改掉漏掉的 Changes

    最終, quasar dev 正確!

  7. 再次 + 並且 ✅ ,然後 push 上去! ok !

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章