About

With a checkout, you can

Specifically, it will check out the files

Checking out a local branch from a remote-tracking branch automatically creates what is called a tracking branch

Example

Switch branch

git checkout branchName

Restore a file 2 commits back

Restore the Makefile to two revisions back from the main branch

git checkout main~2 Makefile

Restore all unstaged files

For all unstaged files use at the root dir:

git checkout -- .

Restore a specific file

git checkout path/to/file

Restore a series of file and directories

git checkout main -- {path/to/dir,path/to/dir2,path/to/file.json}

Support

error: pathspec '.' did not match any file(s) known to git.

Do you perform the checkout from the root directory ?