After installing Git on your machine, the first thing you'll need to do is set up a repository. A repository (i.e., repo) is a centrally located folder for storing all of your code. Once you create a Git repository with your files and directories, you can start tracking changes and versions. In this section, you'll learn how to get a repository up and running.
Remote repositories and local repositories
There are two types of Git repositories: remote and local.
- A remote repository is hosted on a remote, or off-site, server that is shared among multiple team members.
- A local repository is hosted on a local machine for an individual user.
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.
Ways 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 you can clone an existing repository.
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 so that you can start tracking changes.
You can copy a remote repository onto your local machine using the git clone command. By default, git clone will automatically set up a local master branch that tracks the remote master branch it was cloned from.
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.
Ready to set up a repo for yourself? Follow our step-by-step tutorial to create your first Git repo.