简体   繁体   中英

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

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.

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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM