I messed up with one file in one repository and want to check out only that file back to a commit. How to achieve this?

To check the file with my_file.name at git commit commit_sha1:

$ git checkout commit_sha1 my_file.name

You can also use the relative commit instead of commit_sha1 such as master~4, HEAD~4, HEAD^, master^ and etc.

To check back (the master) of myfile.name:

$ git checkout master my_file.name

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *