There is an option --force-with-leasefor git push . Performance
git push --force-with-lease
will do exactly what you want and only force update the remote branch if it is still on the same version as your remote tracking branch (i.e. origin/branch).
You can also specify a revision explicitly if you want to check a different version:
git push --force-with-lease=branch:someCommitHash
source
share