Not exactly. At least, not for the working directory.
Honestly it took me a few minutes to figure out what your question could mean. You're asking if the working directory will end up matcing the checked-out commit after running a command that you say you know sets the working directory to match the checked-out commit, so the question is... a little murky.
But there ARE situations where the working directory will end up different from what's in the checked-out commit. For example, ignored (or otherwise untracked) files will generally be undisturbed. In some cases that's not possible; maybe I have an untracked file named foo
, but the target tree has a file also named foo
at the same path. Different commands handle that differently. (And here it's important to note, checkout commit
is a VERY different command from checkout commit -- path
.) Some commands will clobber your local untracked data (which will then be unrecoverable, at least as far as any git mechanism is concerned), while others will abort and warn you that local changs would be overwritten.
So, it is not strictly correct to say the working tree is "rebuilt" from the target tree - in that the directory is not entirely rm
'd and then recreated from the tree data. Rather, files are added, deleted, or replaced as necessary (which is a more efficient procedure anyway).
For the index: it's harder to show any "symptom" of the index not being fully rebuilt, because there is no analogous concept to untracked files in the index. I would expect git to take advantage of the hashes it stores for everything, so that it again would just change what needs changing instead of fully rebuilding; but I'm not 100% sure in this case and it's an implementation detail that doesn't really matter. If you tell git to set the index to match a commit, the index will match the commit.