how many times did you face this ?
and it fails, and it's normal because git prevents you to update a branch while you would break everything
git push --force
it's dangerous as you can nuke someone else changes and mess the repository for everyone else than you.
Please note that
git push tells you it will cause problem, and by using
--force you are telling it, you don't care at all.
--force may be useful is some narrow, restricted and very rare situation, but on daily basis you don't want to use it.
git push --force-with-lease
Read the following articles about
git push --force-with-lease --force-if-includes
Here is an excellent article about
The differences are really slightly, but they added it for good reasons.
There is unfortunately no git config to ask git to always uses
one way to achieve it is to use an alias
[alias] please = push --force-with-lease --force-if-includes
So next time you will face an error with
git push, you may ask very politely with
git please alias
I'm not sure from where I got this alias, maybe a coworker.
By writing this post, I found a possible source article