The checked out file will overwrite not yet commited changes you did in this file.
This command will check out the file file.example
(which is located in the directory path/to/
) and overwrite any changes you might have made to this file.
git checkout some-branch path/to/file
some-branch
can be anything tree-ish
known to git (see Revision Selection and gitrevisions for more details)
You have to add --
before the path if your file could be mistaken for a file (optional otherwise). No more options can be supplied after the --
.
git checkout some-branch -- some-file
The second some-file
is a file in this example.