From: Junio C Hamano <gitster@pobox.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: git@vger.kernel.org
Subject: Re: Prevent git reset --hard from losing data
Date: Fri, 20 Nov 2026 14:02:16 -0800 [thread overview]
Message-ID: <xmqqqzgfnouv.fsf@gitster.g> (raw)
In-Reply-To: <20261120145444.13061eb7@gandalf.local.home> (Steven Rostedt's message of "Fri, 20 Nov 2026 14:54:44 -0500")
Steven Rostedt <rostedt@goodmis.org> writes:
> Too many times I do a "git reset --hard" in the wrong directory and end up
> losing uncommitted changes. Is there a way to add a configuration to have
> that command check if there's any uncommitted changes and ask if you really
> want to do the reset?
I do not think so. Castrating an existing command without harming
others is a hard thing to do once the tool gains more than a few
hundred of users, and we probably have more users than that.
I think you need to go to the root of the issue. Find out what made
you want to run "git reset --hard" and see if there are less drastic
solution to the same issue. And come up with a way to package that
less drastic solution in a form that would be useful to many people.
That way, people would start using that newer solution and less
often be running "git reset --hard", reducing the risk. When
somebody really needs to do "git reset --hard" or a script that has
happily been running "git reset --hard", it will continue to do the
destructive thing as it was designed to, and everybody will be
happy.
next prev parent reply other threads:[~2026-11-20 22:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 19:54 Prevent git reset --hard from losing data Steven Rostedt
2026-11-20 21:09 ` Mirko Faina
2026-11-20 22:02 ` Junio C Hamano [this message]
2026-11-20 22:15 ` Steven Rostedt
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=xmqqqzgfnouv.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=rostedt@goodmis.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