git 删除本地分支/远程分支
Posted 在奋斗的大道
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了git 删除本地分支/远程分支相关的知识,希望对你有一定的参考价值。
Git 删除本地分支指令:
# 语法
git branch -d 本地分支名称
# 实例
$ git branch -d zzg-mastr
Git 删除远程分支指令:
# 语法
git push origin --delete 远程分支名称
# 实例
git push origin --delete main
Git Bash 控制台:
zzg@LAPTOP-8R0KHL88 MINGW64 /e/idea_workspace (master)
$ git branch -a
* master
remotes/origin/main
remotes/origin/master
zzg@LAPTOP-8R0KHL88 MINGW64 /e/idea_workspace (master)
$ git push origin --delete main
To github.com:zhouzhiwengang/SpringBoot-Project.git
- [deleted] main
zzg@LAPTOP-8R0KHL88 MINGW64 /e/idea_workspace (master)
$ git branch -a
* master
remotes/origin/master
zzg@LAPTOP-8R0KHL88 MINGW64 /e/idea_workspace (master)
$ git checkout -b zzg-mastr origin/master
Switched to a new branch 'zzg-mastr'
M SmartOA/.idea/vcs.xml
A SmartUrban/.idea/vcs.xml
branch 'zzg-mastr' set up to track 'origin/master'.
zzg@LAPTOP-8R0KHL88 MINGW64 /e/idea_workspace (zzg-mastr)
$ git branch -D zzg-master
error: branch 'zzg-master' not found.
zzg@LAPTOP-8R0KHL88 MINGW64 /e/idea_workspace (zzg-mastr)
$ git branch -D zzg-mastr
error: Cannot delete branch 'zzg-mastr' checked out at 'E:/idea_workspace'
zzg@LAPTOP-8R0KHL88 MINGW64 /e/idea_workspace (zzg-mastr)
$ git branch -a
master
* zzg-mastr
remotes/origin/master
zzg@LAPTOP-8R0KHL88 MINGW64 /e/idea_workspace (zzg-mastr)
$ git branch -D zzg-mastr
error: Cannot delete branch 'zzg-mastr' checked out at 'E:/idea_workspace'
zzg@LAPTOP-8R0KHL88 MINGW64 /e/idea_workspace (zzg-mastr)
$ git checkout master
Switched to branch 'master'
M SmartOA/.idea/vcs.xml
A SmartUrban/.idea/vcs.xml
Your branch is up to date with 'origin/master'.
zzg@LAPTOP-8R0KHL88 MINGW64 /e/idea_workspace (master)
$ git branch -d zzg-mastr
Deleted branch zzg-mastr (was 75ffb6e).
以上是关于git 删除本地分支/远程分支的主要内容,如果未能解决你的问题,请参考以下文章