I have a script that auto merges a feature branch into master. It runs periodically.
I want the script to check that the feature branch does in fact have commits to be merged. If there are no commits the script should exit.
I’ve tried the following:
git rev-list --count HEAD
Run while on the feature branch called ‘test’ with no commits this is returning a value of 1, so the script doesn’t exit, even though it should because there are no commits to merge.
Note that I ran git fetch —all before all of these commands.
Also tried the following:
Tried:
git rev-list --count master..
Resulted in error:
fatal: ambiguous argument 'master..': unknown revision or path not in the working tree.
Tried:
git rev-list --count master
Resulted in error:
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Tried:
git rev-list --count master..test
Resulted in error:
fatal: ambiguous argument 'master..test': unknown revision or path not in the working tree.
How do I determine (from a script) if there are commits to merge?