DEV Community

Christophe Colombier
Christophe Colombier

Posted on Edited on

my git aliases: please = git force --with-lease

how many times did you face this ?

git push
πŸ”₯ Jadwal & Hasil: ccoveille/my git aliases please - Info Live Streaming 2026 πŸ”₯ Jadwal & Hasil: ccoveille/my git aliases please - Info Live Streaming 2026

and it fails, and it's normal because git prevents you to update a branch while you would break everything

Some of you may do this, DO NOT !

git push --force
πŸ”₯ Jadwal & Hasil: ccoveille/my git aliases please - Info Live Streaming 2026 πŸ”₯ Jadwal & Hasil: ccoveille/my git aliases please - Info Live Streaming 2026

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.

Some others, more careful, are using this

git push --force-with-lease
πŸ”₯ Jadwal & Hasil: ccoveille/my git aliases please - Info Live Streaming 2026 πŸ”₯ Jadwal & Hasil: ccoveille/my git aliases please - Info Live Streaming 2026

Read the following articles about --force-with-lease vs --force:

Some really careful (and using git version over 2.30) are using this

git push --force-with-lease --force-if-includes
πŸ”₯ Jadwal & Hasil: ccoveille/my git aliases please - Info Live Streaming 2026 πŸ”₯ Jadwal & Hasil: ccoveille/my git aliases please - Info Live Streaming 2026

Here is an excellent article about --force-if-includes

The differences are really slightly, but they added it for good reasons.

ok, but then ?

There is unfortunately no git config to ask git to always uses --force-with-lease whenarticle

g changes.

one way to achieve it is to use an alias

[alias]
please = push --force-with-lease --force-if-includes
πŸ”₯ Jadwal & Hasil: ccoveille/my git aliases please - Info Live Streaming 2026 πŸ”₯ Jadwal & Hasil: ccoveille/my git aliases please - Info Live Streaming 2026

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
https://www.freecodecamp.org/news/git-please-a182f28efeb5/

Top comments (2)

πŸ”₯ Jadwal & Hasil: ccoveille/my git aliases please - Info Live Streaming 2026
 
rizkyzhang profile image
Rizky Zhang •

Thank you for mentioning this great topic!

πŸ”₯ Jadwal & Hasil: ccoveille/my git aliases please - Info Live Streaming 2026
 
ccoveille profile image
Christophe Colombier •

My pleasure, I will try to post things like this on dev.to from now, as I said on this welcome thread.

Hi everyone,

I'm reading dev.to for a while.

I finally decided to create an account as I mostly stopped using Twitter.

I think dev.to will be be better (and safer) place to post things I found by coding or tuning my configs.

A simple dotfiles on github is often not enough no matter how much details you put in comments or commit messages.

I'm happy you liked what I posted