From: Junio C Hamano <gitster@pobox.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Mirko Faina <mroik@delayed.space>, git@vger.kernel.org
Subject: Re: Prevent git reset --hard from losing data
Date: Mon, 23 Nov 2026 15:40:02 -0800 [thread overview]
Message-ID: <xmqqjym33ynh.fsf@gitster.g> (raw)
In-Reply-To: <20261123160009.61bf0bce@gandalf.local.home> (Steven Rostedt's message of "Mon, 23 Nov 2026 16:00:09 -0500")
Steven Rostedt <rostedt@goodmis.org> writes:
> On Fri, 20 Nov 2026 22:09:32 +0100
> Mirko Faina <mroik@delayed.space> wrote:
>
>> You could just reset without the --hard option and restore what you
>> don't want to keep. Otherwise there's the --keep option that aborts the
>> reset if there's local changes, but you'd have to remember to type it
>> out every time.
>
> I just tried it without the --hard and it reminded me why I never use that.
>
> I just wanted to update one of my branches to one of my devel branches and
> did a git reset without the hard and at the end it gives me:
> ...
Yes. In this particular case, it may not be too bad (you can just do
"git diff | git apply -R" to get rid of them), but if path was added or
removed to the index and the working tree relative to the state you are
resetting to, the recovery becomes messier. I never use "git reset" for
the purpose of cleaning things up fot that reason.
next prev parent reply other threads:[~2026-11-23 23:40 UTC|newest]
Thread overview: 9+ 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-23 21:00 ` Steven Rostedt
2026-11-23 23:40 ` Junio C Hamano [this message]
2026-11-30 14:54 ` D. Ben Knoble
2026-11-30 17:11 ` Steven Rostedt
2026-11-30 17:20 ` Steven Rostedt
2026-11-20 22:02 ` Junio C Hamano
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=xmqqjym33ynh.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=mroik@delayed.space \
--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