The git checkout command can be used to:
Before you can checkout, pull or fetch files, you'll need to use the git clone command to clone an origin Git repository to a directory on your local PC. The most basic way to use Git is to use the git clone command to clone an origin Git repository (such as example.git) to a directory on your PC (such as /home/john.doe/git), make a change to a file in the cloned repository on your PC (such as example.txt), use the git commit command to commit the change to the file, and to then use the git push command to upload the file to the origin Git repository.
If your branch already contains a file that is also in the origin Git repository, and there are differences between the files, git pull will attempt to integrate and merge the differences into the files in your branch.
git fetch will download but not merge or integrate any differences between similar files
In this example, foo.txt will be downloaded from the origin Git repository to the currently selected branch of the cloned repository. If no output is returned, this means the commit of the file in the currently selected branch of the cloned repository is exactly the same as the file in the origin Git repository.
git checkout 'path/to/foo.txt'
If the following is returned, this suggests that the file does not exist in the origin Git repository.
~]$ git checkout 'path/to/foo.txt' error: pathspec 'path/to/foo.txt' did not match any file(s) known to git.