git-push - git删除分支 - 如何删除本地和远程的Git分支?

git branch参数 / git / version-control / git-branch / git-remote

我想同时删除本地和远程的分支。

尝试删除远程分支失败。

$ git branch -d remotes/origin/bugfix
error: branch 'remotes/origin/bugfix' not found.

$ git branch -d origin/bugfix
error: branch 'origin/bugfix' not found.

$ git branch -rd origin/bugfix
Deleted remote branch origin/bugfix (was 2a14ef7).

$ git push
Everything up-to-date

$ git pull
From github.com:gituser/gitproject

* [new branch] bugfix -> origin/bugfix
Already up-to-date.

Matthew Rankin



Answer #1

删除远程分支

git push -d origin <branch-name>
git push origin :<branch-name>

强制删除本地分支

git branch -D <branch-name>