删除远程分支的尝试失败 :
$ 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
本地和远程分支?
这是所有其它答案的混结。 它需要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
提示:当您使用删除分支时
git branch -d <branchname> # Deletes local branch
或
git push origin :<branchname> # Deletes remote branch
仅删除引用。 即使该分支实际上在远程删除, 但它的引用仍然存在于您的团队成员所在的本地存储库中 。 这意味着对于其他团队成员来说, 被删除的分支在做一个git branch -a
.
为了解决这个问题,你的团队成员可以使用
git remote prune <repository>
这是典型的git remote prune origin
.
删除分支的步骤 :
删除远程分支 :
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
将分支合并状态的错误丢弃为相应的错误...
我还创造了下方图像以显示步骤:
