Digital Scholarship Resources - Vanderbilt Libraries Digital Scholarship and Communications Office

Previous lesson: GitHub work cycle

GitHub for beginners: Recovering from disaster

In this lesson, you will see several ways to use the commit history of Git to recover from problems you encounter when working with files in a project.

Learning objectives At the end of this lesson, the learner will be able to:

Total video time: 16 m 48 s

Lesson slides

Recovering from increasingly bad disasters

Level 1: Undoing a bad file save (4m23s)


If you want to discard the changes from more than on file, you can select several by holding on the command button (Mac) or Ctrl button (Windows), then clicking on the files you want to select, or clicking on the first file, then holding down the shift and clicking on the last file in a range of files. Then right-click and select Discard x Selected Changes.

Level 2: Reverting a bad commit (4m28s)

Level 2.5: Resolving a version conflict using Atom (4m00s)

Level 2.5: Recovering a deleted file using the file history (4m06s)

Level 3: Recloning the repository (3m57s)

Practice assignment

  1. Edit and save a file without committing it. Then use GitHub Desktop to discard the changes.
  2. Delete a previously committed file (but don’t commit that change). Use GitHub Desktop to recover it by “discarding” the deletion.
  3. Make sure that all changes are committed. Then make some undesirable change to a file, commit that change, then revert that commit to restore the version to the previous commit. (Note: it does not matter whether you have pushed the commit to GitHub or not.)
  4. Use the version history on GitHub Desktop to find the point in time when you revised a file to a particular version that you want to recover. View the diff online and then download the file from that version.
  5. Make sure that all changes that you want are committed and pushed to GitHub. Make any number of changes and commits, but don’t push those commits to GitHub. Remove the repository using GitHub desktop. Then restore the older version of the repository (without the unpushed commits) by recloning it from GitHub.
  6. Simulate a major disaster on your computer by just deleting an entire repository folder. In GitHub Desktop, try to switch to that repository. Can you figure out how to get it back?

Next lesson: issues tracker

Revised 2022-01-31

Questions? Contact us

License: CC BY 4.0.
Credit: "Vanderbilt Libraries Digital Scholarship and Communications -"