I updated files and committed them, e.g.
git add *lots of files*
git add b.txt
git commit -m 'Update files'
Now I realize I actually want to make the changes to b.txt
in a different commit. I want to remove the changes to b.txt
from my commit, but I want to keep the changes in the filesystem. If b.txt
were a new file, I could do this with
git rm --cached b.txt
But this doesn't work for reverting b.txt
to its previous state in the staging area.
Basically, I want to check out directly into the staging area without modifying my local files. Is there a way to accomplish this with a single command in Git?
This question is not a duplicate of Reset or revert a specific file to a specific revision using Git? because that asker wants to change the working tree, but here I don't want to change the working tree.