Overwrite single file in current working directory with the same from another branch

suggest change

The 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.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents