删除远程分支的尝试失败 :

$ 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 :bugfix  # Deletes remote branch
git branch -d bugfix     # Must delete local branch manually

如果您确定要删除,请运行

git branch -D bugfix

现在清理已删除的远程分支, 运行

git remote prune origin

其他回答

删除分行

我们假设我们的分支“联系形式”的工作已经完成,我们已经将其纳入“主人”中。由于我们不再需要它,我们可以删除它(就地):

$ git branch -d contact-form

要删除远程分支 :

git push origin --delete contact-form

删除分支的步骤 :

删除远程分支 :

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将分支合并状态的错误丢弃为相应的错误...

我还创造了下方图像以显示步骤:

Delete a remote and local branch in git

很简单: 只要运行以下命令 :

要删除本地和远程的 Git 分支, 请使用此命令先删除本地分支 :

git branch -d example

(此处example是分支名称。 )

在此之后, 使用此命令删除远程分支 :

git push origin :example

要删除本地本地- (正常)

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.

图形代表:

Enter image description here

这是所有其它答案的混结。 它需要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