简体   繁体   中英

How to only get git commit messages for merges into a particular branch

In our repo we have 3 primary branches.

在此处输入图像描述

  1. development developers branch from development, do their work and merge back into development.
  2. UAT once the client is ready we merge development into UAT
  3. live once UAT passes we merge UAT into live

I would like a list of all git-log commit messages for merges into the development branch.

I would like to exclude all other merges, eg development to some other branch, live to UAT, UAT to dev, dev to UAT.

Currently I have this

git log --merges --since="2022-07-27 16:00:00" --grep='Merged\sPR\s\d+:\s' -P --pretty=oneline 

This will get me all the merge commits

  1. since particular date
  2. I use grep to filter. All the merges I'm interested in have the text "Merge PR 12345" in the message. This filters out merges from development into some other dev branch (pink with green bar in the image).

How to get rid commit messages for merges from live to UAT to development?

The merge message is quite standardize if you don't change it by hand.

For example

git log --all --grep="Merge.*into '\?development'\?" 

Will match commit with

Merge branch 'fix/foo' into development

and

Merge branch 'fix/bar' into 'development'

To follow only the leftmost line in your graph (the blue one), add --first-parent :

git log --oneline --first-parent [other options ...] development

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