删除远程分支不会从GitHub中删除 [英] deleting remote branch does not remove from GitHub

查看:182
本文介绍了删除远程分支不会从GitHub中删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个本地分支,比如 hotfix 。我使用GitHub使用

  $ git push -u原始修补程序

合并分支后,我想删除它。所以我输入

  $ git branch -d hotfix 

在本地删除分支。但是,远程分支仍然在GitHub上。当然,当我看着我的远程分支时,

  $ git branch -r 
origin / HEAD - >原产地/主产地
产地/修补程序
产地/主产地

hotfix 仍然存在。所以然后我尝试

  $ git分支-r -d原点/修补程序
$ git分支-r
origin / HEAD - >原产地/主产地
原产地/主产地

修补程序不见了,如预期的那样。

但是我去了GitHub,看看我的分支, hotfix 仍然存在!如何通过命令行从GitHub删除远程修补程序,而无需在浏览器中导航到GitHub并使用网站UI将其删除?

解决方案

您需要推动删除操作:

  git push origin --delete hotfix 

(any git branch 命令只会影响你的本地回购,而不是GitHub远程回购)



详情请参阅如何在本地和远程删除Git分支?。


$ b $ a git分支-d -r 仅删除
远程跟踪分支 ,即中存在的分支。 remotes / origin 您当地回购的名称空间。 GitHub(实际的远程回购)从未被通知。

成功删除的是远程追踪分支,它位于您的本地仓库中,用于记录您从上游仓库中获取的最后一个SHA1对于那个分支:那是什么远程追踪分支。

正确的顺序是:

  git push origin --delete hotfix 
git remote update --prune origin

这将删除GitHub仓库中的修补程序分支,然后删除仓库中任何过时的远程跟踪分支。


I have a local branch, say hotfix. I put it up on GitHub using

$ git push -u origin hotfix

Then after merging the branch, I want to delete it. So I type

$ git branch -d hotfix

which deletes the branch locally. However, the remote branch is still on GitHub. Of course when I look at my remote branches,

$ git branch -r
  origin/HEAD -> origin/master
  origin/hotfix
  origin/master

hotfix is still there. So then I try

$ git branch -r -d origin/hotfix
$ git branch -r
  origin/HEAD -> origin/master
  origin/master

and hotfix is gone, as expected.

But then I go to GitHub and look at my branches, and hotfix is still there! How can I delete the remote hotfix from GitHub via the command line, without having to navigate to GitHub in my browser and delete it using the Website UI?

解决方案

You need to push that deletion:

git push origin --delete hotfix

(any git branch command would only have an effect on your local repo, not the GitHub remote one)

See more at "How to delete a Git branch both locally and remotely?".

A git branch -d -r only deletes a remote tracking branch, that is branches existing in the remotes/origin namespace of your local repo. GitHub (the actual remote repo) is never notified.

What you have "successfully" deleted is the "remote tracking branch" which is in your local repo and is meant to record the last SHA1 that you fetched from the upstream repo for that branch: that what a "remote tracking branch" is.

The correct sequence is:

git push origin --delete hotfix
git remote update --prune origin

That will delete the hotfix branch on the GitHub repo, and then delete any obsolete remote tracking branch in your repo.

这篇关于删除远程分支不会从GitHub中删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆