How to do Git Log see only merges to master branch?
Asked Answered
I

3

74

In my work process I need to provide a list of files to my server admin. The list comes from the merge of my working branch (Branch A) into Master branch.

So I merge branch A into branch Master and then deploy Master.

Right now the best I could do with git log is the following but this list contains other commit as well ( not only the merge I'm looking for ):
git log -m --name-only --author=[NAME]

So basically I need to retrieve the files list for the merge of Branch A into Master Branch

Is it possible with cli command ?

Imam answered 23/9, 2014 at 3:47 Comment(0)
H
80

Narrow it down using git log --merges --author to figure out the commit you want and then try

git diff --name-only ${MERGE_SHA}^1..${MERGE_SHA}
Hunt answered 23/9, 2014 at 3:55 Comment(0)
G
36

I find it useful to narrow the path to first parent in order to ignore "update branch" merges.

Looks like this for me:

git log r2.8.7-2018-09-04..HEAD --merges --first-parent

Gerfalcon answered 4/10, 2018 at 14:18 Comment(2)
What is "r2.8.7-2018-09-04" in this context?Josettejosey
I'd assume it's a tag or a branch of the latest release.Indeterminism
I
5

I have the following alias configured in git for this purpose:

alias.merges=log --oneline --decorate --color=auto --merges --first-parent

This is useful to see all previous merges to the branches (wtih release tags) useful when updating deployment terraform configs:

$ git merges -5
ad2b1a1 (HEAD -> master, tag: 22.09.00003, origin/master, origin/HEAD) Merge branch 'feature/E' into 'master'
80ca202 (tag: 22.09.00002) Merge branch 'feature/D' into 'master'
8d693c3 (tag: 22.09.00001) Merge branch 'feature/C' into 'master'
09604e4 (tag: 22.09.00000) Merge branch 'feature/B' into 'master'
70285a5 (tag: 22.08.00009) Merge branch 'feature/A' into 'master'

Like previous answers state you can then see difference between releases like:

$ git diff 22.09.00000..22.09.00002
Indeterminism answered 16/9, 2022 at 11:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.