You may get to a point on a lab sometimes and just think it's best to start this lab from scratch. That's OK! Here are some steps you can follow so you can restart the lab and save your old work in case you want to look back on it later.

Step 1: Make sure you are in the correct lab directory by going to Learn.co and clicking the Open button for the lab you are on.

Step 2: Save all your files. One great way to make sure that all your files are saved is by closing all open tabs in the Learn IDE. If that tab is close, then that file must be saved!

Step 3: Add and commit all your files. We can do this by typing two commands into the Learn IDE terminal git add . and git commit -m "Old code that is not working". This will track all your changes using git.

Step 4: Save changes to a new branch. You can do this by typing the following into your Learn IDE Terminal: git checkout -b old-code. This will create a branch for you that has all your old code!

Step 5: Switch back to master. Type the following into your terminal: git checkout master. This will switch you from your new branch, back to the master branch.

Step 6: Find the point you want to roll back to. Type git log into your Learn IDE terminal. This will show you ALL the changes that have been made to this lab since it was first created. What we're looking for here is the most recent SHA (7 digitis to the left of the commit message) that was not done by you. Note: You may have to scroll up in the Learn IDE terminal to find this. Once you have copied the SHA, you can escape out of git log by pressing q.

Step 7: Reset: You can now reset back to this point by typing in git reset --hard <the SHA you copied>. Now this lab is reset to when you first cloned it!

Step 8: Push code to github. To keep your github up to date, run the following commands: git push origin master -f and git push origin old-code:old-code. Note: If you've already pushed up a branch on this lab called old-code, you may need to add -f at the end of this command to overwrite that (as I did in the video).

Check out this video walkthrough to help you through these steps:

Did this answer your question?