# Proposalö git push -F

4 messages from 2021-03-02 to 2021-08-24. Participants: XonqNopp, Junio C Hamano, Johannes Schindelin, Xavier Morel.
Thread: https://gitlist.dev/t/55241

## XonqNopp, 2021-03-02 12:35

Subject: Proposalö git push -F
Message-ID: <CAJU-ojOhSpGraS=Cwy=kMNxNgN=T=o7Eq-BxcAfSLHMzmtAm9Q@mail.gmail.com>
URL: https://gitlist.dev/e/CAJU-ojOhSpGraS%3DCwy%3DkMNxNgN%3DT%3Do7Eq-BxcAfSLHMzmtAm9Q%40mail.gmail.com

```
Hi there,

Thanks for everything you do, git is really an awesome tool and I
enjoy using it!

I have discovered some months ago that it is more safe to force a push with
git push --force-with-lease

But since then I keep wondering: why is this not the default? Maybe we
should have --force (which would be with lease) and
--force-without-lease? That would be more logical for unaware users...
However, I would completely understand your reticence to change this.
I just want to propose to change the shortcuts:

* "git push --force" shortcut would become "git push -F"
* "git push --force-with-lease" would use the shortcut "git push -f"

This is just an idea of mine, I wanted to share it with you. Feel free
to use it or not...

Cheers :-)
XonqNopp

```

## Junio C Hamano, 2021-03-03 06:38

Subject: Re: Proposalö git push -F
Message-ID: <xmqqim68lp20.fsf@gitster.c.googlers.com>
URL: https://gitlist.dev/e/xmqqim68lp20.fsf%40gitster.c.googlers.com
In-Reply-To: <CAJU-ojOhSpGraS=Cwy=kMNxNgN=T=o7Eq-BxcAfSLHMzmtAm9Q@mail.gmail.com>

```
XonqNopp <xonqnoppp@gmail.com> writes:

> I have discovered some months ago that it is more safe to force a push with
> git push --force-with-lease
>
> But since then I keep wondering: why is this not the default?

Because the form "--force-with-lease=<this-exact-commit>" is a
strict improvement over "--force", but the lazy "guess where the
other end should be" form, i.e. "--force-with-lease" alone, is worse
than "--force" in that it gives users false sense of security
without offering the safety the "lease" mechanism gives.



```

## Johannes Schindelin, 2021-03-04 10:02

Subject: Re: Proposalö git push -F
Message-ID: <nycvar.QRO.7.76.6.2103041045420.57@tvgsbejvaqbjf.bet>
URL: https://gitlist.dev/e/nycvar.QRO.7.76.6.2103041045420.57%40tvgsbejvaqbjf.bet
In-Reply-To: <xmqqim68lp20.fsf@gitster.c.googlers.com>

```
Hi,

On Tue, 2 Mar 2021, Junio C Hamano wrote:

> XonqNopp <xonqnoppp@gmail.com> writes:
>
> > I have discovered some months ago that it is more safe to force a push with
> > git push --force-with-lease
> >
> > But since then I keep wondering: why is this not the default?
>
> Because the form "--force-with-lease=<this-exact-commit>" is a
> strict improvement over "--force", but the lazy "guess where the
> other end should be" form, i.e. "--force-with-lease" alone, is worse
> than "--force" in that it gives users false sense of security
> without offering the safety the "lease" mechanism gives.

To add to that: some tools helpfully fetch in the background, therefore
remote-tracking branches are updated _without_ the user being aware of it.
In this instance, `--force-with-lease` is very dangerous.

We did introduce the `--force-if-includes` option, but it seems that we
made this option _not_ imply `--force-with-lease`, which makes it an
unwieldy `git push --force-with-lease --force-if-includes <refspec>`,
which admittedly not even _I_ type, and I really would benefit from this
option.

Maybe it is time to admit that `--force-if-includes` should imply
`--force-with-lease`, and then add `-F` as a shortcut?

Ciao,
Johannes

```

## Xavier Morel, 2021-08-24 10:23

Subject: Re: Proposalö git push -F
Message-ID: <c49da491-f8a3-440f-54e2-295be8dbcfd7@odoo.com>
URL: https://gitlist.dev/e/c49da491-f8a3-440f-54e2-295be8dbcfd7%40odoo.com
In-Reply-To: <xmqqim68lp20.fsf@gitster.c.googlers.com>

```
 > Because the form "--force-with-lease=<this-exact-commit>" is a
 > strict improvement over "--force", but the lazy "guess where the
 > other end should be" form, i.e. "--force-with-lease" alone, is worse
 > than "--force" in that it gives users false sense of security
 > without offering the safety the "lease" mechanism gives.

That seems like a case of the perfect being the enemy of the good.

Generaly, "force with lease" is a better behaviour than "force". It will 
not catch all usage errors, but it will catch lots: again last week 
colleagues had issues which would had been caught by caught by using 
"--force-with-lease" instead" of "-f", but of course "-f" is "the 
default" in rebase-based workflows, what with being so short and sweet.

I found XonqNopp's proposal as I was planning to post a similar message, 
though stricter: I don't think `--force` deserves a short form at all, I 
  believe `-f` should be progressively migrated over to alias to 
`force-with-lease` as it's a significantly better default behaviour, and 
the odd *need* for `--force` (of which I can't personnally remember one) 
can be typed out in its entirety.

For the vast majority of users, all it will do is catch genuine errors. 
For a small minority it will have no effect[0]. And for an infinitesimal 
number it will be unhelpful as `--force` without lease or inclusion is 
genuinely what they were looking for.

I genuinely do not understand what `force-if-includes` does from reading 
the manpage and just learned that it exists from Johannes Schindelin's 
message, it might be an even better default behaviour for `-f`.

Either way I think `-f` should not, ultimately, alias to `--force`.

My idea there was to introduce a setting initially defaulting to `false` 
and a warning about the migration (triggered on `-f` when that setting 
is unset), then a few versions later flip the default to `true`.

[0] and I would expect users of tools which helpfully fetch in the 
background to not be using the CLI, and thus not be impacted by this change.

```
