简体   繁体   English

如何删除没有差异的本地分支机构?

[英]How to remove local branches that have no differences to master?

How can I delete all git branches which have been merged? 如何删除所有已合并的git分支? show how to delete branches that have been merged. 显示如何删除已合并的分支。 However, in GitHub, there is now a "Squash and merge" and a "Rebase and merge" option, both of which is not detected by git branch --merged . 但是,在GitHub中,现在有一个“ Squash and merge”和“ Rebase and merge”选项,这两个选项都没有被git branch --merged检测到。

Is there a way to identify all the branches that essentially generates an empty commit if merged into master? 有没有一种方法可以识别所有合并到master中的分支,这些分支实际上会生成一个空的提交?

EDIT: looking for a programmatic way via the CLI, similar to the linked question. 编辑:通过CLI查找编程方式,类似于链接的问题。

One thing you can compare other branches with master . 一件事,您可以将其他分支与master进行比较。 If no difference found then delete the branch. 如果没有差异,则删除分支。

$ git checkout master

$ git branch           
$ git diff HEAD..branch1      # see what is in 'branch1' that is not in 'master' branch

# if no difference found then delete the branch
$ git branch -D branch1    

The easiest way may be through the GitHub web UI. 最简单的方法可能是通过GitHub Web UI。 Navigate to your repository. 导航到您的存储库。 Click on the number of branches: 单击分支数:

在此处输入图片说明

GitHub groups branches in the repos by Active, Stale, Yours, and Default. GitHub将仓库按Active,Stale,Yours和Default分组在仓库中。 You will find color coded buttons that mark them as Open, Closed, or Merged. 您会发现颜色编码的按钮将它们标记为“打开”,“关闭”或“合并”。 To the right of the button is a trashcan button you can use to delete the branch. 该按钮的右侧是一个垃圾桶按钮,可用于删除分支。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM