简体   繁体   中英

Extracting the correct git log when multiple merges have been made

We have a git workflow where:

  • we use a "project" repository (forked from the "master" repository", which contains a "project" branch (cloned from the latest master tag from the master branch)

  • these project branches are merged into a develop branch, and then cloned into a "staging" branch. There is no single staging branch, but each develop (=each project) branch creates a corresponding staging branch, which is then merged into master after testing.

  • this means that at any point of time, there are multiple staging branches, and multiple project branches

Now, we are running into a constant issue where when there are two staging branches, both created at the same time for separate projects, BUT one of them is going to release before the other. Lets say staging/A releases before staging/B

  • to prevent degradation, we need to merge staging/A INTO project/B, to test the changes made by staging/A before we update staging/B

We do this with a simple merge request (PR), but this pollutes the logs of project/B, which is important because we need to calculate the "step count" (between the master base and project/B). And this pattern of merging another staging branch into a project branch is pretty common and repetitive. Which means there are multiple merges into projects/B that are not part of projects/Bs' changes.

Is there any git command/script that extracts the commits made by project/B only , ignoring the changes made by merges made by staging branches, to correctly calculate the step count that truly represents the changes made in project/B.

Also, if this git workflow has issues, please do let me know - I'm not really a DevOps guy

edit: Just to make it a bit clearer: If there is a branch called "release-1"

git log --oneline release-1

git log --oneline release-1

Once I merge this branch into develop-2

git log --oneline develop-2

发布-1 -> 开发-2

So the logs for develop-2 are polluted with the logs from release-1.
Now, in real-life, there are multiple merges like this into the project branch.

I'd like to extract the commits made in only develop-2 (in this case), and ignoring all the commits that have come in because of merge from external branches

You may be looking for the --first-parent option of git log , and perhaps --no-merges :

git log --graph --first-parent
git log --graph --first-parent --no-merges

If you are using a GUI, look for checkboxes or options with these names.

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