I had a patch I wanted to apply on a fresh branch, and commit. (I was trying to rescue myself from the problem described at this question.) So I did
git apply patchfile
git add file1
git add file2
git add file3
git add file4
where file1..4 were the four files I knew I was patching.
But when I then checked my work, with git status or git diff --cached,
prior to committing to my new branch, I discovered that, for some
as-yet-unknown reason, only file1 and file2 had been patched.
I want to retry the git apply to see what went wrong, but first
I have to reset things to their initial state.
That feels like git reset on at least file1 and file2, but
since I've already added those files to the cache, I'm pretty
sure I want reset --hard. But when I do
git reset --hard file1
it says fatal: Cannot do hard reset with paths.
I'm sure there's a good reason for this, and (whatever it is) it
probably means that reset --hard was not what I wanted to do.
Can anyone explain?
(Perhaps I just wanted a fresh git checkout, not necessarily git reset.
I guess I'm not sure what the difference is between checkout and reset.)
Update: This question is confused, and doesn't make much sense. I suspect I'll delete it soon.
Mostly I wanted to undo a git add, and I had misread my notes, and concluded that reset --hard was what I wanted. But no, that's wrong; the way to undo a git add is with a simple git reset. No --hard required. (And then, having reset the index, I believe I do want a git checkout to restore the working file, as suggested by Tim Roberts in a comment.)