Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check whether a branch has been merged into another branch?

Tags:

git

In command line, how can I check whether a branch has been merged into another branch, and if yes, find out which branch it has been merged into?

like image 361
Tim Avatar asked Mar 15 '17 21:03

Tim


2 Answers

git branch --contains <branch>

will print all local branches where the commit labelled by <branch> is an ancestor.

like image 176
SzG Avatar answered Sep 22 '22 07:09

SzG


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)

--contains []
Only list branches which contain the specified commit (HEAD if not specified)

git branch --contains <commit/tag/branch>

enter image description here

like image 35
CodeWizard Avatar answered Sep 21 '22 07:09

CodeWizard