Difficulty: Beginner
Estimated Time: 10 minutes

In this scenario you'll learn how to initialise a new Git repository and commit files into version control.

Version control allows you to record changes to a file or set of files over time enabling you to go back to a specific version if required. Git is a Distributed Version Control System. This means that instead of having a snapshot of the latest files, you have a complete mirror of the repository on your local machine. The repository keeps track of the changes, when they occurred and who by. Having the complete repository on your local machine reduces delays due to network traffic and enables you to continue working when disconnected.

This Scrapbook environment has been pre-configured with git installed. For more information on installing Git, please refer to the official documentation.

This scenario has explained how you can initialise a repository and then commit files to it. In the next scenario we'll investigate how to compare and commit changes to these files. In future scenarios we'll cover how to share these changes with other people.

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 1 - Committing Files

Step 1 of 5

Step 1 - Git Init

To store a directory under version control you need to create a repository. With Git you initialise a repository in the top-level directory for a project.

Task

As this is a new project, a new repository needs to be created. Use the git init command to create a repository.

ProTip

After initialising a repository, a new hidden subdirectory called .git is created. This subdirectory contains the metadata that Git uses to store it's information. If you're interested in the details then use the command line to explore the contents.