Hacker News new | ask | show | jobs
by hkdobrev 1355 days ago
This works like this for uncommitted files, because `git reset --hard` would try to remove any files it knows about. After staging the file, even if you just do it with `git add --intent-to-add`, git would already _know_ about this file.

And then, it seems you expected to be able to run a command which would undo your previous command of staging the file. However, git-reset was never meant to do that. You might argue, it's not aptly named.

git-reset tries to reset the files it knows about to the state in the supplied ref or HEAD. After you told git about a file, it tries to control it even if it's not persisted in its internal objects.

This is true in git for various plumbing and porcelain commands.

On whether that's surprising or not - _it might be_ to people new to git, but as a whole git CLI is not that welcoming to newcomers.