Records for the last 24 hours are added to the wizard

I am trying to show the commits (excluding merge commits) that have been added to the master branch in the last 24 hours. I am currently using this command for this:

 git log --format=format:%s --no-merges --since='24 hours ago' 

However, this has a problem: if the commit is older than 24 hours, but in the last 24 hours it enters the master branch, the command will not list the commit. Is it possible to show commits added to the master branch in the last 24 hours and not earned in the last 24 hours?

Please note that I am doing this in a clean CI workspace, so git reflog cannot help me.

Thanks in advance!

+7
git git-log
source share
1 answer

I think rev-list is what you want.

Try the following:

 git rev-list --no-merges '^<24-hour-old-commit>' HEAD 

This should contain a list of all non-merge commits that are reachable from commit HEAD but not reachable from commit <24-hour-old-commit> .

For example, in this revision chart, he lists upper case, but not lower case:

 a - b - c - 24h - H - i - J - K - HEAD \ / D - E - F - G ' 

Records H , J , K and HEAD all younger than 24 hours. Commit i also younger, but is omitted since this is a merge union. Commits D , E , F and G can be of any age, but have been combined only in the last 24 hours, so they are also listed.


In the above command, the --max-age or --since will have the same problem as you have with git log , but you can use them to search for <24-hour-old-commit> for you:

 git rev-list -n1 --before="24 hours" --first-parent HEAD 

That is, "indicate only 1 commit identifier, which must be at least 24 hours in the current branch."

Putting it all together:

 git rev-list --no-merges HEAD \ --not $(git rev-list -n1 --before="24 hours" --first-parent HEAD) 

(Note: --not abcdef is another way to say ^abcdef , except that it applies to all of the following arguments, hence reordering the parameters.)

The default output rev-list by default is just raw revisions, but you can make it look more like git log with the --pretty . --pretty=short about the same as you are used to.

+3
source share

All Articles