Intro: We are a team of 10 people actively working on one project. Updates are released very often and it happens that after the changes are published to our GitHub repository, the branch immediately becomes out-of-date with remote master branch, there is no need to run CI/CD and everything else on it, before it gets updated.
For example, I'm working on a feature branch, pushing it to a remote repository, and opening a new pull request. But I cannot know in advance whether my branch is updated according to the master or not. Before each push, I need to manually update the local master branch and do a rebase.
To reduce actions I would like to set up a git pre-push hook
that automatically checks if the current branch that I want to push is out of date relative to the master - if so, cancel the push.
On the GitHub page it shows this message: This branch is out-of-date with the base branch
Any ideas how to get this information and cancel pushing to remote? Thanks.