Git:如何找到所有从未合并回master的分支

时间:2013-10-29 06:16:43

标签: git branching-and-merging

我们有一个相当大的GIT仓库,我想删除那些从未合并回主人的分支。

反过来也很好 - 一种列出在某些时候合并为master的所有分支的方法。

我希望得到一个列表,而不是立即删除分支,因为有些分支可能值得保持静止或者最近处于开发状态。

所以问题是:有没有办法列出所有从未将任何更改合并回的分支?

2 个答案:

答案 0 :(得分:14)

git branch --no-merged master

或者换句话说,git branch --merged master

docs

答案 1 :(得分: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