sunzeal
sunzeal

Reputation: 17

How to see previously committed version of file in Git

I have created a folder name A and have ran git init ( which initialized ).

Under it I created 2 files a.txt and b.txt and than ran git add . and then git commit.

Now those files were committed.

Now if I do modification to a.txt and save it, but want to checkout the original file ( saved during commit in local repository ) how can I do it ?

PS: I am doing it in CentOS server where GIT is installed, so it itself is a local repository and I want to fetch data from it.

Upvotes: 0

Views: 87

Answers (1)

iberbeu
iberbeu

Reputation: 16215

If you want to get the version of the file that was just commited:

git checkout -- <path-to-file>

Be aware that if is a folder it will be applied recursively

If you just want to see the old file version:

git show COMMIT:<path-to-file>

Upvotes: 5

Related Questions