git刪除遠端分支和本地分支以及更改本地和分支名字 git-更改本地和遠端分支的名稱
阿新 • • 發佈:2018-11-16
問題描述:
當我們集體進行專案時,將自定義分支push到主分支master之後,如何刪除遠端的自定義分支呢
問題解決:
(1)使用命令git branch -a 檢視所有分支
注:
其中,remote/origin/master表示的是遠端分支
(2)刪除遠端分支
注:
如上所示,使用命令 git push origin --delete Chapater6 可以刪除遠端分支Chapater6
再次使用命令 git branch -a 可以發現,遠端分支Chapater6已經被刪除。
(3)刪除本地分支
使用命令,git branch -d Chapater8 可以刪除本地分支(在主分支中)
注:
如上圖所示,在從Chapater8分支切換到master分支,git checkout master
然後使用 git branch -d Chapater8 可以刪除Chapater8分支。
git-更改本地和遠端分支的名稱
git branch -m old_branch new_branch # Rename branch locally git push origin :old_branch # Delete the old branch git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
注:紅色為標註!不需要鍵入!