Exploring History

Overview

Teaching: 25 min
Exercises: 0 min
Questions
  • How can I access old versions of files?

  • How do I review my changes?

Objectives
  • Use the GitHub website to look back in time.

  • Compare various versions of tracked files.

  • Restore old versions of files.

The easiest way to access old versions of your repository, or of individual files, is via the GitHub website. This does mean that your repository has to be hosted on GitHub or a similar service (e.g. Bitbucket). It is possible to do this on the command line instead, but we don’t recommend it for novices.

Start by navigating to your repository’s page on GitHub. On that page there is a little clock icon with the number of commits you’ve made to that repository.

Commits icon

If you click on it, you will see a list of all the commits you (and any collaborators) have made, including each one’s commit message.

Commits list

Hopefully your commit message will be informative enough that you will be able to identify which one contains the version you’re looking for. At the right side of each row there are three mysterious-looking boxes.

The rightmost box, which looks like angle brackets (<>) is a link to the whole repository, as it was when that commit was made. If you click on it (ideally open it in a new tab), you will see a list of all the files the repository contained at that point, and you can click on individual file names to view, and even download, those files. If your files are not plain text, viewing them may not work properly, but you should always be able to download them and then view them on your computer. Just be careful not to overwrite the version in your local repository by accident!

Going back to our commit list, the middle of the three mysterious boxes, which will contain 7 apparently random letters or numbers, will let you view the changes made between this commit and the one before it. Again, this only works on plain text files, but if your files are R scripts or something similar it can be quite useful.

Key Points

  • The GitHub website will show a list of changes, and show the differences between commits.

  • We can download or copy from old versions of files.