git學習筆記之分支管理
創建分支
- 創建分支
git checkout branch_name
- 切換分支
git checkout branch_name或者是git switch branch_name
- 創建 + 切換分支
git checkout -b branch_name或者是git switch -c branch_name
- 顯示分支
git branch
- 在分支中編輯文件內容
切換到 branchone分支,在readm.txt文件中添加
然後git add 和git commit到分支上
- 合併分支
git merge branchname
注意:合併分支是要先回到master上才能進行merge操作。
我開始是先進行merge然後切換到master上,但是在分支上進行的修改並沒有被合併到master上。
Fast-forward 是快進模式,不是每次合併都能快進。 - 刪除分支
git branch -d branchname
例如刪除branchone