Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - How to see if a branch has EVER been merged into another branch?

If I have a feature branch F and master branch M, then

git branch --merged

while on master will show me if F has been entirely merged into M, but how can I tell if it has EVER been merged?

I've tried looking through the git-log manual and from what I can tell

git log M..F

will show me the revs on F that haven't been merged into M. I'd like to see the inverse of that, the revs on F that have been merged into M.

There are a whole bunch of questions which are close to this but don't seem to cover this particular case.2

like image 796
SimonF Avatar asked Jun 14 '12 10:06

SimonF


2 Answers

Use git log:

git log feature_branch master --oneline --date-order --merges --reverse -1

This will show you all merges betwee feature_branch and master. --reverse will output the commits in reverse order. And -1 means to show only one commit. Therefore you'll see only the first merged commit.

If this is an empty output than it means nothing is merged. If you want you can remove the -1 at the end to show all merged commits beginning with the latest.

like image 175
Fatih Arslan Avatar answered Oct 23 '22 00:10

Fatih Arslan


1. lists the branches that are already merged

git branch --merged 

2. lists the branches that have not been merged (if its not there that means its merged)

git branch --no-merged 
like image 36
Sumit Singh Avatar answered Oct 23 '22 02:10

Sumit Singh