I have two primary branches within a Git repository - develop and master. New feature development occurs in branches off of develop, which are then merged into master for deployment.
I would like to determine if a merge has occurred from develop into master since a certain time. I'm not even really interested in the actual commits themselves, only that something from develop has been merged into master.
I have tried:
git rev-list --merges origin/develop..origin/master --since <date> | wc -l
for a period where I know there are merges, but it always seems to return a zero.
Update
Also, I have tried to build it up, step-by-step. Starting with:
git rev-list --merges origin/master --since <date>
I get all of the merges into master, both from the develop branch and any hotfix branches that may exist. It's only when I add the 'origin/develop' constraint that I get nothing in the results.
In order to find the last time a branch was merged in, I would use git merge-base
. This shows the latest commit that both the branches have in common.
git merge-base origin/develop origin/master
This will provide the latest common SHA in both branches giving you an idea when they were last merged. You can pipe the commit SHA into git log
and see the last commit.
git merge-base origin/develop origin/master | xargs git log -1
If you want to see all the commits on the branch since this SHA:
git merge-base origin/develop origin/master | xargs -I sha git log sha..origin/develop
With this you will be able to see a list of all the commits made on origin/develop
that are not yet on origin/master
.