AFAIK there is no configuration available to tell git to always use force-with-lease
instead of force
. This seems to be a good example for a feature request; if you have no problem to dive into the git code base you could implement it yourself and submit it for review.
EDIT As it stands, this is still true in February 2021.
Until then the only option I see is, as so often, to create an alias
which serves this purpose.
Create an alias
To create an alias one would use git config --global alias.<alias-name> <command>
, in our case I would suggest something similar to this.
git config --global alias.pushfwl "push --force-with-lease"
This will create an entry in your global .gitconfig
file (which you can usually find in your home directory). After this you can simply use git pushfwl
to force-with-lease.
Get your hands dirty
If you want to implement the feature yourself but aren't sure where to start, you should at first take a look at the documentation directory in the git repository. Here you can find the coding guidelines and information on how to submit patches.
You can find all these links and more on the official community page.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…