When you say
git checkout foo
without additional arguments, you're telling git to replace the foo
in your worktree with the foo
in your index. So if you've add
ed (i.e. staged, i.e. updated the index with) all the changes to foo
, then of course there's nothing for this checkout
command to do.
The normal procedure to back out the change would be to first reset
(update the index from the HEAD
commit) and then use checkout
to update the working version.
Then again, you can use checkout
to get the version of foo
from the previous commit
git checkout HEAD foo
This works just as well; the two-step approach is probably just a bit more widely known since it uses commands suggested by git status
for un-staging and un-doing changes.