Did a merge occur from a specific branch into master?
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.
- How do you store static data in your SQL Server Database Project in VS 2012
- Git push origin master getting 'origin' doesn't appear to be a git repository
- Introduction to Mercurial
- How delete the last git commit after pushing to remote then pulling from remote master branch to local
- git: switch branch without detaching head
- How to substitute text from files in git history?
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.
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.
2 Solutions collect form web for “Did a merge occur from a specific branch into master?”
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
Another option should be:
git log --merges --since=<date> --oneline origin/develop..origin/master
- –merges tells log to only show merges
- –oneline is optional and formats the output