Last Updated: February 25, 2016
·
31.51K
· willybarro

Retrieve single file from old commit on GIT

To retrieve a single file from an old commit to your working copy, simply use:

$ git checkout [revision_hash] [file_name]

You can use the HEAD pointer as the [revision_hash] if you want to:

  • HEAD - Points to the Last Commit on the current repository;

  • HEAD^ - Last Commit - 1;

  • HEAD^^ - Last Commit - 2;

  • HEAD~10 - 10 commits behind of HEAD;