Using git log to display files changed during merge

前端 未结 2 781
有刺的猬
有刺的猬 2020-12-24 07:45

I’m executing the following command:

git log --name-only –pretty=\"format:%H %s\" -- *.sql --grep=\"JIRA-154\"

which returns results in the

2条回答
  •  悲哀的现实
    2020-12-24 08:17

    The reason you are observing this behavior is that in the case of a merge commit there are two sets of changed files, one coming from each parent. One option here would be to use the --first-parent -m options when running your git log:

    git log --name-only --grep="JIRA-154" --first-parent -m –-pretty="format:%H %s" -- "*.sql"
    

    This will tell Git to focus onlg on the main branch into which the merge is happening, showing the set of files for this commit only.

    Check here for the documentation and here for a great blog post.

提交回复
热议问题