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.

Git- 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.


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


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.