Try   HackMD

Git 支線Branch創建與Merge合併

Sharon Mai20230523, Tue

↪️總目錄:Git and GitHub相關

情境:當有多人同時分工開發或開發新功能測試,但不想影響到主架構程式,需要使用分支開發卻並ok在合併到主架構程式中。

指令說明
指令 說明
git branch ai_test 創建支線與命名
git branch 查詢現有主線與支線
git checkout - 來回切換支線
git checkout master 切換到指定支線
git merge prj_test 合併支線

創建

  • 創建支線與命名
    ​​​​git branch ai_test
    

查詢

  • 查詢現有主線與支線
    ​​​​git branch(有*為當前所在分支位置)
    
    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

切換

  • 來回切換支線
    ​​​​git checkout -
    
    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

切換指定

  • 切換到指定支線
    ​​​​git checkout master
    

合併

合併支線Branch

  1. 切到要合併其他支線的主線或分支(此以主線合併支線為例)
    ​​​​git checkout master
    
  2. 合併支線
    ​​​​git merge ai_test
    
  3. 完成!