$ git remote show origin
• remote origin
Fetch URL:git@github.com:liugl/proj.git
Push URL:git@github.com:liugl/proj.git
HEAD branch: master
Remote branches:
master tracked
dev tracked
Local branches configured for'git pull':
master merges with remote master
dev merges with remote dev
Local refs configured for'git push':
master pushes to master (up to date)
dev pushes to dev (up to date)
$ git push origin --delete dev
To github.com:liugl/proj.git
• [deleted] dev $ git branch -a • master
dev
remotes/origin/HEAD -> origin/master
remotes/origin/master
1.
2.
3.
4.
5.
6.
7.
8.
如上删除中,使用 git push 命令删除远程 git 分支后,并没有删除本地分支。
删除HEAD分支
HEAD 分支是默认分支的别名,在大多数存储库中,默认分支为 master 或者 main。
接下来我们尝试一下删除远程默认分支...
$ git branch -a • master
dev
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/dev $ git push origin --delete master
To github.com:liugl/proj.git
! [remote rejected] master (refusing to delete the current branch: refs/heads/master)
error: failed to push some refs to 'github.com:liugl/proj.git'
我有话说: