# Short form of --force-with-lease

7 messages from 2024-04-11 to 2024-04-12. Participants: Wyatt Carpenter, Kipras Melnikovas, rsbecker@nexbridge.com, Kyle Lippincott, Junio C Hamano.
Thread: https://gitlist.dev/t/61309

## Wyatt Carpenter, 2024-04-11 17:16

Subject: Short form of --force-with-lease
Message-ID: <CADwVmK293eQ5VFkn-J68tXQ=64u3H79ScMW7H_ukSmtwLwA4wA@mail.gmail.com>
URL: https://gitlist.dev/e/CADwVmK293eQ5VFkn-J68tXQ%3D64u3H79ScMW7H_ukSmtwLwA4wA%40mail.gmail.com

```
I often use git push --force-with-lease; it does exactly what I need.
Is there a short form of the flag, like -f is for --force? If not, I
would like to propose -l be added as one. I don't believe git push has
an -l flag currently, and l is of course the first letter of lease.

```

## Kipras Melnikovas, 2024-04-11 17:36

Subject: Re: Short form of --force-with-lease
Message-ID: <20240411173639.81152-2-kipras@kipras.org>
URL: https://gitlist.dev/e/20240411173639.81152-2-kipras%40kipras.org
In-Reply-To: <CADwVmK293eQ5VFkn-J68tXQ=64u3H79ScMW7H_ukSmtwLwA4wA@mail.gmail.com>

```
I have also thought about this.

I'd suggest a config option "push.forceFlagBehavior" that would allow to
configure the behavior, one of:
- "default" / "overwrite", which is currently -f,
- "lease" for --force-with-lease,
- "lease-includes"  for --force-with-lease --force-if-includes,
- possibly others.

Then, upon `git push -f`, the config option would be consulted to determine the
behavior.

To get the default behavior, `-f -f` or `-F` could be used.


```

## rsbecker@nexbridge.com, 2024-04-11 19:21

Subject: RE: Short form of --force-with-lease
Message-ID: <01e101da8c45$66d33240$347996c0$@nexbridge.com>
URL: https://gitlist.dev/e/01e101da8c45%2466d33240%24347996c0%24%40nexbridge.com
In-Reply-To: <20240411173639.81152-2-kipras@kipras.org>

```
On Thursday, April 11, 2024 1:37 PM, Kipras Melnikovas wrote:
>I'd suggest a config option "push.forceFlagBehavior" that would allow to
configure
>the behavior, one of:
>- "default" / "overwrite", which is currently -f,
>- "lease" for --force-with-lease,
>- "lease-includes"  for --force-with-lease --force-if-includes,
>- possibly others.
>
>Then, upon `git push -f`, the config option would be consulted to determine
the
>behavior.
>
>To get the default behavior, `-f -f` or `-F` could be used.

If this is mostly about saving typing, you could get a similar effect adding
an alias. Something like

git config --global alias.pushfl 'push --force-with-lease'


```

## Kipras Melnikovas, 2024-04-11 20:32

Subject: Re: Short form of --force-with-lease
Message-ID: <20240411203225.82557-2-kipras@kipras.org>
URL: https://gitlist.dev/e/20240411203225.82557-2-kipras%40kipras.org
In-Reply-To: <01e101da8c45$66d33240$347996c0$@nexbridge.com>

```
> If this is mostly about saving typing, you could get a similar effect adding
> an alias. Something like
> 
> git config --global alias.pushfl 'push --force-with-lease'

Correct, and I already have an alias:
'pf = push --force-with-lease --force-if-includes'.

However, I see the config option more valuable - it would protect against
accidental `push -f`, which, out of habit, is very probable to run on accident.
With the config option, would feel safe and wouldn't need the alias either.

Thanks.


```

## Kyle Lippincott, 2024-04-11 20:58

Subject: Re: Short form of --force-with-lease
Message-ID: <CAO_smVhB0QUomdSxGqwvFKrb53NGMZE+y=3zbRnQX+ciLRZyOw@mail.gmail.com>
URL: https://gitlist.dev/e/CAO_smVhB0QUomdSxGqwvFKrb53NGMZE%2By%3D3zbRnQX%2BciLRZyOw%40mail.gmail.com
In-Reply-To: <20240411203225.82557-2-kipras@kipras.org>

```
On Thu, Apr 11, 2024 at 1:34 PM Kipras Melnikovas <kipras@kipras.org> wrote:
>
> > If this is mostly about saving typing, you could get a similar effect adding
> > an alias. Something like
> >
> > git config --global alias.pushfl 'push --force-with-lease'
>
> Correct, and I already have an alias:
> 'pf = push --force-with-lease --force-if-includes'.
>
> However, I see the config option more valuable - it would protect against
> accidental `push -f`, which, out of habit, is very probable to run on accident.
> With the config option, would feel safe and wouldn't need the alias either.

It would normalize the use of `push -f` in people's muscle memory,
which would be a potential disaster if someone lost their
configuration, but not this muscle memory. It also would break
automation/scripts - `git push` is likely used by both humans and
automation (custom one-off automation like a personal script, or
automation shared by many people) - if they're expecting `git push -f`
to do the legacy behavior, then it'll break things if the meaning of
`-f` changes. A separate flag (or just using an alias if it's for
saving typing) would be safer.

>
> Thanks.
>
>

```

## Junio C Hamano, 2024-04-11 21:30

Subject: Re: Short form of --force-with-lease
Message-ID: <xmqq7ch3r3i3.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqq7ch3r3i3.fsf%40gitster.g
In-Reply-To: <01e101da8c45$66d33240$347996c0$@nexbridge.com>

```
<rsbecker@nexbridge.com> writes:

> If this is mostly about saving typing, you could get a similar effect adding
> an alias. Something like
>
> git config --global alias.pushfl 'push --force-with-lease'

The use of --force-with-lease without specifying which commit you
took lease on is not all that safe [*], so I am not sure how useful
such an alias will be.

Configuring how "--force" behaves and changing it to an unadorned
"--force-with-lease" is to promote a not-so-safe feature as if it is
safe with false sense of safety, which is not something we would
want to do.


[Footnote]

 * This of course highly depends on your workflow and third-party
   companion tools.  If you (or your IDE in the background) fetch
   from the remote after you started working on the commit to be
   force-pushed, it would update the tip of the remote-tracking
   branch, making --force-with-lease base its decision on a wrong
   commit that your work is not based on.

```

## Kipras Melnikovas, 2024-04-12 09:00

Subject: Re: Short form of --force-with-lease
Message-ID: <20240412090035.87612-2-kipras@kipras.org>
URL: https://gitlist.dev/e/20240412090035.87612-2-kipras%40kipras.org
In-Reply-To: <CAO_smVhB0QUomdSxGqwvFKrb53NGMZE+y=3zbRnQX+ciLRZyOw@mail.gmail.com>

```
> > > If this is mostly about saving typing, you could get a similar effect adding
> > > an alias. Something like
> > >
> > > git config --global alias.pushfl 'push --force-with-lease'
> >
> > Correct, and I already have an alias:
> > 'pf = push --force-with-lease --force-if-includes'.
> >
> > However, I see the config option more valuable - it would protect against
> > accidental `push -f`, which, out of habit, is very probable to run on accident.
> > With the config option, would feel safe and wouldn't need the alias either.
> 
> It would normalize the use of `push -f` in people's muscle memory,
> which would be a potential disaster if someone lost their
> configuration, but not this muscle memory. It also would break
> automation/scripts - `git push` is likely used by both humans and
> automation <...>. A separate flag (or just using an alias if it's for
> saving typing) would be safer.

Fair point, I retract my config option proposal.
A separate flag, as proposed by OP, would make more sense. Thanks.


```
