Difficulty: Beginner
Estimated Time: 10 minutes

One of the main advantages when using a version control system is the ability to undo changes and return to a previous version. Git provides powerful approaches and control over managing your repository and it's history which we'll explore in this scenario.

In this scenario the environment has been created with a Git repository with a number of simple commits.

This scenario demonstrated how you can reset and revert changes you've made and how to go back to a previous state.

This scenario has been added to your scrapbook where you can review the examples and commands you executed.

Don’t stop now! The next scenario will only take about 10 minutes to complete.

Scenario 4 - Undoing Changes

Step 1 of 5

Step 1 - Git Checkout

When working with Git, a common scenario is to undo changes in your working directory. The command git checkout will replace everything in the working directory to the last committed version.

If you want to replace all files then use a dot (.) to indicate the current directory, otherwise a list the directories/files separated by spaces.

Task

Use git checkout to clear any changes in the working directory.