Overwrite single file in current working directory with the same from another branch
suggest changeThe checked-out file overwrites uncommitted changes in that file, in both the index and the working tree.
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)
Add -- before the path if the path could be mistaken for a revision (optional otherwise). No options can be supplied after --.
git checkout some-branch -- some-file
The second some-file is a file in this example.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents