6

我们有一个相当大的 GIT 存储库,我想删除从未合并回 master 的分支。

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

我想要一个列表开始,而不是简单地立即删除分支,因为某些分支可能值得保持静止或最近一直在开发中。

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

4

2 回答 2

17

git branch --no-merged master

或者换一种方式,git branch --merged master

文档

于 2013-10-29T06:18:21.353 回答
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).

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

于 2013-10-29T06:19:52.807 回答