Remote repositories and local repositories

There are two types of Git repositories: remote and local.

While you can take advantage of Git version control features with a local repository, collaboration features—like pulling and pushing code changes with teammates—will be better suited on a remote repository.

How to create a repository

There are two ways to create a local repository on your machine. You can create a new repository from scratch using a file folder on your computer or clone an existing repository.

Git init

You can create a new repo from scratch using the git init command. It can be used to introduce Git into an existing, unversioned project in order to start tracking changes.

Git clone

Use the git clone command to copy a remote repository onto your local machine.

By default, git clone automatically sets up a local master branch that tracks the remote master branch it was cloned from.

Note

A cloned repository has the same history log as the original one. You can refer and backtrack to any of those commits within your local repository.