删除远程分支的尝试失败 :
$ 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.
我如何正确删除本地和远程的远程/原产/bugfix分支?
删除远程分支的命令行的替代选项是 GitHub 分支页面。
例如,见:https://github.com/agorm/agorgon.js/branches。
在代码 - > GitHub 库的分支页面中找到 。
我一般更喜欢指挥行本身,但这个 GitHub 页面显示您对分支的更多信息,例如最新日期和用户,以及前后承诺的数量。 这对于处理大量分支很有用。
如果您想要用一个命令来完成这两个步骤, 您可以在 ~ /. gitconfig 中添加下面的替代名称 :
[alias]
rmbranch = "!f(){ git branch -d ${1} && git push origin --delete ${1}; };f"
或者,您可以从命令行使用
git config --global alias.rmbranch \
'!f(){ git branch -d ${1} && git push origin --delete ${1}; };f'
注:如果使用 -d(小写d),该分支只有在合并时才被删除。要强制删除,您需要使用 -D(大写D)。