{"thread":{"id":"55241","subject":"Proposalö git push -F","startedAt":"2021-03-02T15:28:37Z","lastAt":"2021-08-24T10:39:43Z","messageCount":4,"participants":["XonqNopp","Junio C Hamano","Johannes Schindelin","Xavier Morel"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"418104","messageId":"CAJU-ojOhSpGraS=Cwy=kMNxNgN=T=o7Eq-BxcAfSLHMzmtAm9Q@mail.gmail.com","threadId":"55241","inReplyTo":null,"subject":"Proposalö git push -F","fromName":"XonqNopp","fromEmail":"xonqnoppp@gmail.com","sentAt":"2021-03-02T12:35:53Z","receivedAt":"2021-03-02T15:28:37Z","isPatch":false,"sender":{"key":"xonqnoppp@gmail.com","avatar":null},"body":"Hi there,\n\nThanks for everything you do, git is really an awesome tool and I\nenjoy using it!\n\nI have discovered some months ago that it is more safe to force a push with\ngit push --force-with-lease\n\nBut since then I keep wondering: why is this not the default? Maybe we\nshould have --force (which would be with lease) and\n--force-without-lease? That would be more logical for unaware users...\nHowever, I would completely understand your reticence to change this.\nI just want to propose to change the shortcuts:\n\n* \"git push --force\" shortcut would become \"git push -F\"\n* \"git push --force-with-lease\" would use the shortcut \"git push -f\"\n\nThis is just an idea of mine, I wanted to share it with you. Feel free\nto use it or not...\n\nCheers :-)\nXonqNopp\n"},{"id":"418131","messageId":"xmqqim68lp20.fsf@gitster.c.googlers.com","threadId":"55241","inReplyTo":"CAJU-ojOhSpGraS=Cwy=kMNxNgN=T=o7Eq-BxcAfSLHMzmtAm9Q@mail.gmail.com","subject":"Re: Proposalö git push -F","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-03-03T06:38:31Z","receivedAt":"2021-03-03T06:59:57Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"XonqNopp <xonqnoppp@gmail.com> writes:\n\n> I have discovered some months ago that it is more safe to force a push with\n> git push --force-with-lease\n>\n> But since then I keep wondering: why is this not the default?\n\nBecause the form \"--force-with-lease=<this-exact-commit>\" is a\nstrict improvement over \"--force\", but the lazy \"guess where the\nother end should be\" form, i.e. \"--force-with-lease\" alone, is worse\nthan \"--force\" in that it gives users false sense of security\nwithout offering the safety the \"lease\" mechanism gives.\n\n\n"},{"id":"418228","messageId":"nycvar.QRO.7.76.6.2103041045420.57@tvgsbejvaqbjf.bet","threadId":"55241","inReplyTo":"xmqqim68lp20.fsf@gitster.c.googlers.com","subject":"Re: Proposalö git push -F","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2021-03-04T10:02:18Z","receivedAt":"2021-03-04T12:11:12Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 2 Mar 2021, Junio C Hamano wrote:\n\n> XonqNopp <xonqnoppp@gmail.com> writes:\n>\n> > I have discovered some months ago that it is more safe to force a push with\n> > git push --force-with-lease\n> >\n> > But since then I keep wondering: why is this not the default?\n>\n> Because the form \"--force-with-lease=<this-exact-commit>\" is a\n> strict improvement over \"--force\", but the lazy \"guess where the\n> other end should be\" form, i.e. \"--force-with-lease\" alone, is worse\n> than \"--force\" in that it gives users false sense of security\n> without offering the safety the \"lease\" mechanism gives.\n\nTo add to that: some tools helpfully fetch in the background, therefore\nremote-tracking branches are updated _without_ the user being aware of it.\nIn this instance, `--force-with-lease` is very dangerous.\n\nWe did introduce the `--force-if-includes` option, but it seems that we\nmade this option _not_ imply `--force-with-lease`, which makes it an\nunwieldy `git push --force-with-lease --force-if-includes <refspec>`,\nwhich admittedly not even _I_ type, and I really would benefit from this\noption.\n\nMaybe it is time to admit that `--force-if-includes` should imply\n`--force-with-lease`, and then add `-F` as a shortcut?\n\nCiao,\nJohannes\n"},{"id":"433538","messageId":"c49da491-f8a3-440f-54e2-295be8dbcfd7@odoo.com","threadId":"55241","inReplyTo":"xmqqim68lp20.fsf@gitster.c.googlers.com","subject":"Re: Proposalö git push -F","fromName":"Xavier Morel","fromEmail":"xmo@odoo.com","sentAt":"2021-08-24T10:23:23Z","receivedAt":"2021-08-24T10:39:43Z","isPatch":false,"sender":{"key":"xmo@odoo.com","avatar":"https://gravatar.com/avatar/42b8eb16dcf3bd6c1998698115b36ab6f4d69f93710caa10ff8ab04a9652ae34?d=mp&s=160"},"body":" > Because the form \"--force-with-lease=<this-exact-commit>\" is a\n > strict improvement over \"--force\", but the lazy \"guess where the\n > other end should be\" form, i.e. \"--force-with-lease\" alone, is worse\n > than \"--force\" in that it gives users false sense of security\n > without offering the safety the \"lease\" mechanism gives.\n\nThat seems like a case of the perfect being the enemy of the good.\n\nGeneraly, \"force with lease\" is a better behaviour than \"force\". It will \nnot catch all usage errors, but it will catch lots: again last week \ncolleagues had issues which would had been caught by caught by using \n\"--force-with-lease\" instead\" of \"-f\", but of course \"-f\" is \"the \ndefault\" in rebase-based workflows, what with being so short and sweet.\n\nI found XonqNopp's proposal as I was planning to post a similar message, \nthough stricter: I don't think `--force` deserves a short form at all, I \n  believe `-f` should be progressively migrated over to alias to \n`force-with-lease` as it's a significantly better default behaviour, and \nthe odd *need* for `--force` (of which I can't personnally remember one) \ncan be typed out in its entirety.\n\nFor the vast majority of users, all it will do is catch genuine errors. \nFor a small minority it will have no effect[0]. And for an infinitesimal \nnumber it will be unhelpful as `--force` without lease or inclusion is \ngenuinely what they were looking for.\n\nI genuinely do not understand what `force-if-includes` does from reading \nthe manpage and just learned that it exists from Johannes Schindelin's \nmessage, it might be an even better default behaviour for `-f`.\n\nEither way I think `-f` should not, ultimately, alias to `--force`.\n\nMy idea there was to introduce a setting initially defaulting to `false` \nand a warning about the migration (triggered on `-f` when that setting \nis unset), then a few versions later flip the default to `true`.\n\n[0] and I would expect users of tools which helpfully fetch in the \nbackground to not be using the CLI, and thus not be impacted by this change.\n"}]}