Deleting the remote branch failed. How to delete the remote branch?
Isn’t it written that there is no "new" branch on the remote server? Has it been deleted by someone else?
Remove local tracking
#Deleting a local remote-tracking branch:
git branch --delete --remotes <remote>/<branch>
git branch -dr <remote>/<branch> # Shorter
刪除遠(yuǎn)程分支和tag
在Git v1.7.0 之后,可以使用這種語法刪除遠(yuǎn)程分支:
$ git push origin --delete <branchName>
刪除tag這么用:
git push origin --delete tag <tagname>
否則,可以使用這種語法,推送一個空分支到遠(yuǎn)程分支,其實就相當(dāng)于刪除遠(yuǎn)程分支:
git push origin :<branchName>
這是刪除tag的方法,推送一個空tag到遠(yuǎn)程tag:
git tag -d <tagname>
git push origin :refs/tags/<tagname>
兩種語法作用完全相同。
刪除不存在對應(yīng)遠(yuǎn)程分支的本地分支
假設(shè)這樣一種情況:
我創(chuàng)建了本地分支b1并pull到遠(yuǎn)程分支 origin/b1;
其他人在本地使用fetch或pull創(chuàng)建了本地的b1分支;
我刪除了 origin/b1 遠(yuǎn)程分支;
其他人再次執(zhí)行fetch或者pull并不會刪除這個他們本地的 b1 分支,運行 git branch -a 也不能看出這個branch被刪除了,如何處理?
使用下面的代碼查看b1的狀態(tài):
$ git remote show origin
* remote origin
Fetch URL: git@github.com:xxx/xxx.git
Push URL: git@github.com:xxx/xxx.git
HEAD branch: master
Remote branches:
master tracked
refs/remotes/origin/b1 stale (use 'git remote prune' to remove)
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
這時候能夠看到b1是stale的,使用 git remote prune origin 可以將其從本地版本庫中去除。
更簡單的方法是使用這個命令,它在fetch之后刪除掉沒有與遠(yuǎn)程分支對應(yīng)的本地分支:
git fetch -p
http://zengrong.net/post/1746...
To play git, I recommend you read the blogs of two people, one is Liao Xuefeng and Liao Xuefeng’s git tutorial
The second one is Ruan Yifeng, Ruan Yifeng git tutorial
Indicates that the remote branch corresponding to this branch is in stale status and synchronizes the local repository. Command: git remote update origin --prune
git remote update origin --prune
git pull -p
git pull -p
I usually use this
But you have to manually delete the branch locally.