git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Proposalö git push -F

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Mar 4, 2021, 10:02 UTC
Message-ID
<nycvar.QRO.7.76.6.2103041045420.57@tvgsbejvaqbjf.bet>
In-Reply-To
<xmqqim68lp20.fsf@gitster.c.googlers.com>
Hi,
On Tue, 2 Mar 2021, Junio C Hamano wrote:
Show 12 quoted lines
> 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

Previous: Junio C HamanoNext: Xavier Morel
Message 3 of 4 in “Proposalö git push -F”
  1. XonqNoppMar 2, 2021
  2. Junio C HamanoMar 3, 2021
  3. Johannes SchindelinMar 4, 2021
  4. Xavier MorelAug 24, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.