Search code examples
gitrepositorygit-mergegit-diff

Git: List the number of branches merged to Master but not on Release branch


I am using Git repository. I have a Release branch which is behind Master branch. I normally merged development branches to the Master and only QA verified branches merged to Release. Is there anyway to list out the branches which have been merged to Master but not merged to Release branch? This way it will be easy for me to list out which are the branches have been merged to Master also merged to Release.


Solution

  • You can list the merged branches with git branch --merged <branch name>. So in your case you'd run

    $ git branch --merged Master
    ... branches ...
    $ git branch --merged Release
    ... branches ...
    

    and look for branches that appear in the first output but not the second. I'm sure it's possible to do a oneliner but I'm no shell guru.

    Depending on whether you want to include remote branches or list only remote branches you have to use the -a or -r flags respectively.