How to Git- Getting older version of project

In this guide, we are going to learn how to getting older version. Going back in history is very simple. The checkout command can copy any snapshot from the repository to the working directory.

View Previous Versions

To Get the list of changes, use git log command.  You should get output that looks something like this:


  $ git log
  commit 27304a3559a73142b9c6d056efbe4dcda770cc2c
  Author: Anwar YP <>
  Date:   Sat Jan 14 10:05:58 2017 +0530

      second.txt commited

  commit 13c21d2603681a2061c529e45a0b09e5cf095d48
  Author: Anwar YP <>
  Date:   Sat Jan 14 10:00:32 2017 +0530

      Moved file commited

  commit 93ec701ce8dbab2394484324b865d3c46f951f01
  Author: Anwar YP <>
  Date:   Sat Jan 14 09:35:41 2017 +0530

      Renamed file commited

  commit f38b4096e9e83107c7e71d4c2cd3863fb8971f5f
  Author: Anwar YP <>
  Date:   Fri Jan 13 21:10:52 2017 +0530

      commited the deletion of second.txt


It displays the list of all the commits to the repository. By default, with no arguments, git log lists the commits made in that repository in reverse chronological order. A huge number and variety of options to the git log command are available to show you exactly what you’re looking for.

To get online history, use --pretty=oneline option with git log. Example


View Logs
   $ git log --pretty=oneline
   27304a3559a73142b9c6d056efbe4dcda770cc2c second.txt commited
   13c21d2603681a2061c529e45a0b09e5cf095d48 Moved file commited
   93ec701ce8dbab2394484324b865d3c46f951f01 Renamed file commited
   f38b4096e9e83107c7e71d4c2cd3863fb8971f5f commited the deletion of second.txt

Getting Older Versions

Getting an older version of the project is very simple. The git checkout command can copy any snapshot from the repository to the working directory.

git checkout updates files in the working tree to match the version in the index or the specified tree. Let’s go back to our older version  “Renamed file commit” which is third in our log. Copy the hash from the corresponding log and paste it at the end of checkout command.


Git Checkout
  yp@yp-PC MINGW64 ~/lauyou (master)
  $ git checkout 93ec701<br>Note: checking out '93ec701'.

  You are in 'detached HEAD' state. You can look around, make experimental
  changes and commit them, and you can discard any commits you make in this
  state without impacting any branches by performing another checkout.

  If you want to create a new branch to retain commits you create, you may
  do so (now or later) by using -b with the checkout command again. Example:
   git checkout -b <new-branch-name>

  HEAD is now at 93ec701... Renamed file commited

  yp@yp-PC MINGW64 ~/lauyou ((93ec701...))


git checkout command checked out the hash (commit number) version from log list.

For more documentation, check git documentation.

Muhsin Yakkiparamban

Muhsin Yakkiparamban is the co-founder of Lauyou Learning. Muhsin holds Bachelor Degree in Civil Engineering from KMCT Calicut.

You may also like...