Wojtek
Wojtek

Reputation: 1390

How to get list of branches "merged" to git tag

We are tagging master with release number. I want to get list of branches that were merged to master branch before a specific release tag was created.

I could do it by hand calling git tag --contains last_commit_of_each_branch but I'm lazy.

Is there a better way to do it? Or should I just script getting all branches and calling contains for last commits in each of those?

Upvotes: 1

Views: 1883

Answers (1)

Marina Liu
Marina Liu

Reputation: 38106

First, find the branches which were merged into master by git branch --merged master. Assume the branches merged into master are branch1, branch2,…,branchn.

Second, check if a branch or some branches added tags on the last commit of each branch.

Check if branchx added tag on the last commit: git tag --contains branchx.

Check if branchm and branchn added tags on the last commits: git tag --contains branchm --contains branchn.

Of cause, you can use script to achieve it and it’s more time saving.

Upvotes: 2

Related Questions