Here is more info to complement Christophe’s answer and help understand what git checkout does:
git-checkout - Checkout a branch or paths to the working tree
branch
git checkout <branch> is used to switch branch by updating the index and the files in the working tree, and by pointing HEAD at the specified branch.
Any changes to the files in the working tree are kept, so that they can later be committed to the <branch>.
pathspec
git checkout <pathspec> updates files in the working with versions from the index (staging area) rather than from another branch.
From the man page:
git checkout [-p|--patch] [<tree-ish>] [--] <pathspec>...
When <paths> or --patch are given, git checkout does not switch branches. It updates the named paths in the working tree from the index file or from a named <tree-ish> (most often a commit).
If the file changes had been added to the index (aka staging area) using git add, their changes would not have been lost by a git checkout . since this command uses the changes stored in the index to update the specified paths.
This command can be helpful if the changes you made were accidental, e.g., if you deleted a directory in your working directory and then realised that you really needed to keep it, running git checkout <dirname> would restore all the (tracked) files in that directory from the index.
It’s just a pity that it doesn’t warn the user when it updates files and directories changes by irreversibly discarding any changes.