Git: How to find all branches that were never merged back into master

前端 未结 2 920
夕颜
夕颜 2021-01-19 01:13

We have a fairly large GIT repo and I would like to remove branches that were never merged back into master.

The reverse is fine too - a way to list all branches tha

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-19 01:31

    git help branch says:

       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  argument is
       missing it defaults to HEAD (i.e. the tip of the current branch).
    

    Hence, for finding all branches already merged to master you can use git branch --merged master.

提交回复
热议问题