Git:如何查找所有未合并回主分支的分支

6
我们有一个相当大的GIT仓库,我想删除那些从未合并回主分支的分支。
反之亦然 - 一种列出所有曾经合并到主分支的分支的方法。
我希望首先获得一个列表,而不是立即删除这些分支,因为有些分支可能仍然有价值或者最近一直在开发中。
所以问题是:有没有一种方法可以列出所有从未将其更改合并回主分支的分支?
2个回答

17

git branch --no-merged master

这个命令用于列出所有没有合并到主分支的分支。

或者,使用git branch --merged master来列出已经合并到主分支的分支。

文档


1

git help branch 说:

   With --contains, shows only the branches that contain the named commit
   (in other words, the branches whose tip commits are descendants of the
   named commit). With --merged, only branches merged into the named
   commit (i.e. the branches whose tip commits are reachable from the
   named commit) will be listed. With --no-merged only branches not merged
   into the named commit will be listed. If the <commit> argument is
   missing it defaults to HEAD (i.e. the tip of the current branch).

因此,要查找已合并到主分支的所有分支,您可以使用git branch --merged master

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接