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
You can use the git merge-base command to find the latest common commit between the two branches. If that commit is the same as your branch head, then the branch has been completely merged.
4 Answers. Show activity on this post. then it will show you branches which have been merged into the current HEAD (so if you're on master , it's equivalent to the first command; if you're on foo , it's equivalent to git branch --merged foo ).
Suppose you are on branch master and you want to check if the git merge origin/devel will work. Then just do: git merge-tree `git merge-base origin/devel master` master origin/devel .
When you perform a merge, you effectively merge one branch into another—typically a feature branch or bug fix branch into a main branch such as master or develop. Not only will the code changes get merged in, but also all the commits that went into the feature branch.
comm -12 <(sort <(git branch --no-merged master)) <(sort <(git branch --merged integration))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With