删除远程分支的尝试失败 :
$ 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分支?
这是所有其他答案的拼图。 它需要 Ruby 1.9. 3 +, 并且只在 OS X 上测试 。
调用此文件 git- remove, 让它可执行, 并把它放在您的路径中。 然后使用, 例如, git 删除临时 。
#!/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
最初的几种方法对我行不通。
假设你有以下分支和远程分支,
Local : Test_Branch
Remote: remotes/origin/feature/Test_FE
正确设置上方为您本地分支以跟踪您想要删除的远程分支 。
git branch --set-upstream-to=remotes/origin/feature/Test_FE Test_Branch
然后删除远程分支执行此任务
git push origin --delete Test_Branch
然后删除本地分支,按照命令执行
git branch -D Test_Branch
就是这样。
删除分支的步骤 :
删除远程分支时:
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
解释一下:请解释一下这里发生了什么!
简单地做 git 推源 - 删除只删除您的远程分支, 在结尾处添加分支的名称, 这将同时删除并推到远程...
Git 分支 - D, 仅删除本地分支!
-D 代表 --delete --force,它会删除分支,即使它没有合并(force development),但您也可以使用 -d 表示 --delete,它会抛出分支合并状态的错误...
我还创造下面的图像,以显示步骤:
调