pgqlkq
Last Updated: July 09, 2018
·
39.11K
· dsci

Git: checkout a single file from a specific commit

git

Sometimes we mess around with a file and than there is a desire to have a particular state of this file back to the workspace.

That's pretty easy in Git and well discussed on the internets. However, maybe as a personal reminder, it can be achieved like the following:

git checkout <COMMIT#> <path/to/the/messed/up/file>

Example:

git checkout f08a63ff4fa7b8479f8c698e5998ee1afcac3a4e Gemfile

1 Response
Add your response

30136

In addition, adding the -p option allows you to interactively apply a patch of the file if you only need a subset of the file contents.

7 months ago ·