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,git,github)