From: Junio C Hamano <gitster@pobox.com>
To: Aditya Garg <gargaditya08@live.com>
Cc: git@vger.kernel.org
Subject: Re: Question: is there a possibility of getting a warning before a git push -f
Date: Mon, 09 Jun 2025 11:42:16 -0700 [thread overview]
Message-ID: <xmqqldq0rc3b.fsf@gitster.g> (raw)
In-Reply-To: <PN0PR01MB95880EAA98466C9AB049BA44B86BA@PN0PR01MB9588.INDPRD01.PROD.OUTLOOK.COM> (Aditya Garg's message of "Mon, 09 Jun 2025 22:16:52 +0530")
Aditya Garg <gargaditya08@live.com> writes:
> One thing I sometimes encounter is that I sometimes git push -f and
> moments later I realise I did it at the wrong time, result being a
> disaster. I was wondering if a little [y/N] warning could be possible
> before the risky command gets executed. I saw the code for push
> superficially and I don't think it's implemented. I think it would be
> a nice feature though.
I suspect that an even nicer feature that is more generally
applicable is a patch to your shell to make any command you give it
is not run for a few seconds to give you a chance to kill it with
^C. You do not want to run around castrating a bunch of commands
and features like "git push", "rm", ">overwrite-with-redirect", and
all the other "destructive" things you may regret doing. There are
literally too many.
Quite honestly, "-f" or "--force" should be a hint enough that the
user wants the command to do what the command usually does not allow
them to do to avoid potentially dangerous operations.
I would expect that many people will truly get annoyed when "git
anycommand --force" starts asking "That's very dangerous---are you
sure?" for confirmations, and would complain "Yes, otherwise I
wouldn't be giving you '--force'---just do it as I told you".
next prev parent reply other threads:[~2025-06-09 18:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-09 16:46 Question: is there a possibility of getting a warning before a git push -f Aditya Garg
2025-06-09 18:42 ` Junio C Hamano [this message]
2025-06-09 18:44 ` Aditya Garg
2025-06-11 23:18 ` D. Ben Knoble
2025-06-12 11:49 ` Aditya Garg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqldq0rc3b.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=gargaditya08@live.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox