Dan Fabulich Dan Fabulich - 1 year ago 108
Git Question

push --force-with-lease by default

I just learned about

git push --force-with-lease
. It's pretty awesome. But, of course, I don't use force that often, and so I'm worried that I might forget about this nifty feature the next time I need it.

Is there a way to configure git so
git push -f
will automatically use
unless I intentionally override it with

(I can't imagine ever wanting to use force without lease!)

Answer Source

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 May 2016.

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.pushf "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 pushf 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 this links and more on the offical community page.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download