Git: checkout a single file from a specific commit
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
Written by Daniel Schmidt
Related protips
2 Responses
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.
over 1 year ago
·
Thanks for the great advice
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Git
Authors
Related Tags
#git
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#