删除远程分支的尝试失败 :
$ 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.
我如何正确删除remotes/origin/bugfix
本地和远程分支?
删除分支的步骤 :
删除远程分支 :
git push origin --delete <your_branch>
删除地方分支,你已经三种方式:
1: git branch -D <branch_name>
2: git branch --delete --force <branch_name> # Same as -D
3: git branch --delete <branch_name> # Error on unmerge
解释:OK, 解释一下这里发生了什么!
简单做git push origin --delete
至删除您的远程分支仅仅,在结尾处添加分支的名称,这将删除和将它推到远程同时...
还有git branch -D
,它简单地删除了本地分支仅仅!...
-D
代表--delete --force
将会删除分支, 即使它没有合并( 强制删除) , 但是您也可以使用-d
代表--delete
将分支合并状态的错误丢弃为相应的错误...
我还创造了下方图像以显示步骤:

要删除本地本地- (正常)
git branch -d my_branch
如果分行进展迟缓,而且未适当完成,那表示你们是误入歧途的。Rebase/Merge in progress
,在这种情况下,你将无法删除你的分支。
所以要么你要么你需要解决 重新定位/合并的问题。 否则,你可以用武力删除删除通过使用,
git branch -D my_branch
删除偏远:
git push --delete origin my_branch
您可以使用 :
git push origin :my_branch # Easy to remember both will do the same.
图形代表:

这是所有其它答案的混结。 它需要Ruby 1.9. 3+, 并经过测试仅仅OS X上写着
调用此文件git-remove
,然后使用,例如,git remove temp
.
#!/usr/bin/env ruby
require 'io/console'
if __FILE__ == $0
branch_name = ARGV[0] if (ARGV[0])
print "Press Y to force delete local and remote branch #{branch_name}..."
response = STDIN.getch
if ['Y', 'y', 'yes'].include?(response)
puts "\nContinuing."
`git branch -D #{branch_name}`
`git branch -D -r origin/#{branch_name}`
`git push origin --delete #{branch_name}`
else
puts "\nQuitting."
end
end