git工具學習筆記:分支
阿新 • • 發佈:2018-12-10
git branch命令
檢視分支
–list < pattern> 匹配查詢,展示名稱符合pattern的分支 -a 所有分支:本地分支,遠端追蹤分支 -r 遠端追蹤分支 –contains < commit> 包含某次提交的所有分支
建立分支
git branch < branchName> -t –track git branch -t b1 b2 以b2為upstream建立b1分支
重新命名分支
-m –move < old> < new>
跟蹤分支
-u –set-upstream-to
刪除分支
-d 刪除分支 -D 強制刪除 -rd 刪除遠端跟蹤分支
本地分支與遠端分支
1.建立本地分支時跟蹤遠端分支
-t –track
2.本地分支關聯遠端分支
-u –set-upstream-to
3.本地分支推送到遠端
git push < remote repo> [+] < src> :< dest>
3.本地刪除遠端分支
Pushing an empty < src> allows you to delete the < dst> ref from the remote repository. git push 的src引數為空會刪除遠端分支
git push –prune 沒有本地對應分支的遠端分支 git push -d 刪除遠端分支