git學習筆記(4)

git學習筆記之分支管理

創建分支

  1. 創建分支
    git checkout branch_name
    在這裏插入圖片描述
  2. 切換分支
    git checkout branch_name或者是git switch branch_name
    在這裏插入圖片描述
  3. 創建 + 切換分支
    git checkout -b branch_name或者是git switch -c branch_name
    在這裏插入圖片描述
  4. 顯示分支
    git branch
    在這裏插入圖片描述
  5. 在分支中編輯文件內容
    切換到 branchone分支,在readm.txt文件中添加
    在這裏插入圖片描述
    然後git addgit commit到分支上
    在這裏插入圖片描述
  6. 合併分支
    git merge branchname
    注意:合併分支是要先回到master上才能進行merge操作。
    我開始是先進行merge然後切換到master上,但是在分支上進行的修改並沒有被合併到master上。
    在這裏插入圖片描述
    Fast-forward 是快進模式,不是每次合併都能快進。
  7. 刪除分支
    git branch -d branchname
    例如刪除branchone
    在這裏插入圖片描述
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章