Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please DO NOT tell people to run git reset HEAD~ --hard on their master because they might have yet untracked files #144

Open
tjbulick opened this issue Aug 26, 2022 · 1 comment

Comments

@tjbulick
Copy link

tjbulick commented Aug 26, 2022

The instruction block from the website is screenshoted below.

I just ran into such situation right now. While the approach itself is good, this can completely delete newly created files and there would be almost no options to restore them.
I think you should consider deleting this block from the site in favor of always doing git reset HEAD~ --soft because it's more safe. I think plenty of people have lost their changes thanks to you. Don't advise people to do so, this is harmful advise. Or you should at least mention this in red and CAPS ON.
image
Should be always superseded with (because it's more safe):
image

@JKrag
Copy link

JKrag commented Sep 22, 2022

I would suggest a cleaner solution of keeping the original instructions, but replacing --hard with --keep which is the safer version of hard that aborts if you have any local changes that would be lost.
Doing this would avoid the danger of loosing un-commited changes, but still keep the relatively simple 3-step workflow described.

Relevant snippet from git help reset:

--keep
               Resets index entries and updates files in the working tree that are different between <commit> and
               HEAD. If a file that is different between <commit> and HEAD has local changes, reset is aborted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants