Reputation: 9873
TL;DR: How do I find only those merge commits, that merge into a specific branch?
I have roughly this commit history:
f → g → - - - - k → l → m [m] ← feature/2
/ / \
/ / \
/ / \
a → b → - - - - - - h → - - - - n → o [o] ← master
\ / \ /
\ / \ /
\ / \ / [e] ← feature/1
c → d → e i → j [j] ← feature/3
a
- initial commit in master
h
- merge commit from feature/1
to master
k
- merge commit from master
to feature/2
n
- merge commit from feature/3
to master
o
- merge commit from feature/2
to master
Currently, all commits are in master
, and all branches except for master
are gone (push -d
).
I'm trying to find only those merge commits that are directed towards master
; these are h
, n
, and o
. The commit k
is not included because it goes from master.
I'm trying this command:
git rev-list a..o --merges
… but it returns all four merge commits, including k
.
How do I find only "merge to master
" commits? Ideally, this shouldn't involve parsing commit messages, since those can be changed before the merge (at least, in GitHub).
Upvotes: 1
Views: 137
Reputation: 51870
Try adding the --first-parent
option :
git rev-list --first-parent --merges master
# or :
git rev-list --first-parent --merges a..o
If your master
branch can only be updated through merge requests, this will actually always work.
Upvotes: 0