How to check out a file from a specific commit in Git

By Patricia Sauer ·

A person in blue denim jacket using macbook pro

Sometimes you want to check out a file as it was on a specific commit. You can do this easily by using the Git checkout command:

git checkout commitSha -- insertFileNameHere

To check out the file Controller.java, you could do the following:

git checkout 61b04017a359339d191143cc5a2269bf06acd9e2 -- Controller.java

Reference

For full reference see Git checkout documentation.

More about Git

All articles →