Get an old version of a file on Git


When you need to get an old version of a file from git, follow the steps below:

Find the version you want:

git log -p [folder or file path]

It will return the list of changes (something like this)

commit c0924180dba243f12dcbd63c2eb52d7a7472ed5a
Author: Rodrigo De Presbiteris <>
Date: Fri Dec 8 14:03:55 2017 +0000

Some comments

diff --git a/file.txt b/file.txt
index 3c69a57..36f8855 100644
Binary files a/file.txt and b/file.txt differ

commit f367ba1747618abe502a61e317d87730e6bfbb04 (origin/branch_name)
Author: Rodrigo De Presbiteris <>
Date: Wed Dec 6 11:57:09 2017 +0000

Commit comments are shown here

diff --git a/file.txt b/file.txt
new file mode 100644
index 0000000..3c69a57

Now you have to copy the commit hash and run the command below:

 git show [commit_hash]:file.txt > ~/Desktop/file.txt

You will get the old version of the file generated in the destination you defined.