I have a Git repository and I\'d like to see how some files looked a few months ago. I found the revision at that date; it\'s 27cf8e84bb88e24ae4b4b3df2b77aab91a3735d8<
Get the file from a previous commit through checking-out previous commit and copying file.
git checkout 27cf8e84bb88e24ae4b4b3df2b77aab91a3735d8
git checkout theBranchYouNoted
git commit -m "added file ?? from previous commit"
This will help you get all deleted files between commits without specifying the path, useful if there are a lot of files deleted.
git diff --name-only --diff-filter=D $commit~1 $commit | xargs git checkout $commit~1
The easiest way is to write:
git show HASH:file/path/name.ext > some_new_name.ext
where:
git show 27cf8e84bb88e24ae4b4b3df2b77aab91a3735d8:my_file.txt > my_file.txt.OLD
This will save my_file.txt from revision 27cf8e as a new file with name my_file.txt.OLD
It was tested with Git 2.4.5.
If you want to retrieve deleted file you can use HASH~1
(one commit before specified HASH).
EXAMPLE:
git show 27cf8e84bb88e24ae4b4b3df2b77aab91a3735d8~1:deleted_file.txt > deleted_file.txt
You need to provide the full path to the file:
git show 27cf8e84bb88e24ae4b4b3df2b77aab91a3735d8:full/repo/path/to/my_file.txt