From: Steven Rostedt <rostedt@goodmis.org>
To: Mirko Faina <mroik@delayed.space>
Cc: git@vger.kernel.org
Subject: Re: Prevent git reset --hard from losing data
Date: Mon, 23 Nov 2026 16:00:09 -0500 [thread overview]
Message-ID: <20261123160009.61bf0bce@gandalf.local.home> (raw)
In-Reply-To: <awC0MJDYS88yEtgm@exploit>
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:
$ git diff | diffstat
.clippy.toml | 21
.editorconfig | 27
.pylintrc | 2
/dev/null |binary
AGENTS.md | 1
Documentation/.renames.txt | 1185
Documentation/ABI/obsolete/automount-tracefs-debugfs | 20
Documentation/ABI/obsolete/sysfs-driver-ivpu | 30
Documentation/ABI/obsolete/sysfs-driver-samsung-laptop | 10
Documentation/ABI/obsolete/sysfs-kernel-kexec-kdump | 71
Documentation/ABI/obsolete/sysfs-platform-ideapad-laptop | 8
Documentation/ABI/removed/sysfs-class-cxl | 272
Documentation/ABI/removed/sysfs-driver-uniwill-laptop | 10
Documentation/ABI/removed/sysfs-firmware-efi-vars | 12
Documentation/ABI/removed/sysfs-selinux-user | 12
Documentation/ABI/stable/configfs-nvmet | 352
Documentation/ABI/stable/sysfs-class-bluetooth | 9
[...]
tools/virtio/linux/mod_devicetable.h | 14
tools/virtio/linux/ucopysize.h | 21
tools/virtio/linux/virtio_features.h | 79
tools/virtio/oot-stubs.h | 10
tools/virtio/ringtest/.gitignore | 7
tools/virtio/vhost_net_test.c | 527
tools/workqueue/wq_dump.py | 255
tools/workqueue/wq_monitor.py | 168
tools/writeback/wb_monitor.py | 172
usr/dummy-include/limits.h | 8
usr/dummy-include/stddef.h | 13
usr/dummy-include/stdint.h | 17
usr/dummy-include/string.h | 12
usr/dummy-include/sys/socket.h | 12
usr/dummy-include/sys/time.h | 3
virt/kvm/guest_memfd.c | 1446
virt/kvm/guest_memfd.h | 43
72642 files changed, 2141941 insertions(+), 13317958 deletions(-)
This is why I always use --hard with git reset.
I'll use a script to get what I want.
Thanks,
-- Steve
next prev parent reply other threads:[~2026-11-23 21:00 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 [this message]
2026-11-23 23:40 ` Junio C Hamano
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=20261123160009.61bf0bce@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=git@vger.kernel.org \
--cc=mroik@delayed.space \
/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