Git分支在本地回购合并,但仍在Github上可见 [英] Git branch merged on local repo but still visible on Github
问题描述
我为我的项目使用 Git Flow ,并且已完成将我的特性分支合并到我的 develop
分支中的 git flow特性完成
步骤。
然后我执行了 git push
到GitHub,但是在GitHub上我仍然看到了特性分支以及 develop
。
当我在本地运行 git branch
时,我只看到开发
和 master
,这正是我期望的。
我从GitHub中移除分支?我可以应付这个问题,但是如果每个功能都发生这种情况,我最终会得到一大堆旧分支。
非常感谢。
origin
remote引用您的GitHub存储库,您可以删除合并的分支: git push origin:现在合并分支的名称
为了进一步解释语法,当你这样做时:
git push origin some-branch
...
some-分支
参数实际上是一个 refspec ,它定义源名称和目标名称之间的映射,通常采用格式< source-name>:< destination-name>
。如果在refspec中没有:
,它假定你的意思是some-branch:some-branch
。说我只想删除远程分支的方式是完全错过< source-name>
,最后只是以:
后跟远程分支名称。I'm using Git Flow for my project, and have completed the
git flow feature finish
step that merged my feature branch into mydevelop
branch.I then performed
git push
to GitHub, but on GitHub I still see the feature branch as well asdevelop
.When I run
git branch
locally, I only seedevelop
andmaster
, which is what I'd expect.How can I remove the branch from GitHub? I could cope with this one, but if this happens for every feature I'll end up with a massive list of old branches.
Many thanks in advance.
解决方案Assuming the
origin
remote refers to your GitHub respository, you can delete the merged branch with:git push origin :name-of-now-merged-branch
To explain that syntax further, when you do:
git push origin some-branch
... the
some-branch
parameter is actually a "refspec" which defines a mapping between a source name and a destination name, usually of the form<source-name>:<destination-name>
. If there's no:
in the refspec, it assumes that you meansome-branch:some-branch
. The way to say "I just want to delete the remote branch" is to miss out the<source-name>
completely, just ending up with:
followed by the remote branch name.这篇关于Git分支在本地回购合并,但仍在Github上可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!