简体   繁体   中英

Git list branches merged into a branch but not into another

Here is a example graph of branch/commit history:

A---  master
|\
| B-----G--------P feature2
|\       \        \
| -----F--J--L--O--Q integration
|\    /     /  /
| C--E--H--K  /    feature1
 \           /
  D---------M feature3

In a normal circumstances, we merge integration branch into master and done. But... there are exceptional cases where only some specific feature must be merged into master... ex: only feature1. In that case, feature1 branch is merged into master (commit R):

A-------------------------R   master
|\                       /
| B-----G--------P      /     feature2
|\       \        \    /
| -----F--J--L--O--Q  /       integration
|\    /     /  /     /
| C--E--H--K--/------         feature1
 \           /
  D---------M                 feature3

Question: I would like a command that would tell me which branches are merged in integration but not in master. Result should be: feature2 and feature3.

Is a cross-reference between these 2 commands the only way ?

git branch --no-merged master
git branch --merged integration

Or, it could be also a command that list merge commits in integration branch not present in master. Result should be: J,O,Q

 comm -12 <(sort <(git branch --no-merged master)) <(sort <(git branch --merged integration))

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