What is a Repository?
Let's understand what exactly a repository is first and then look at Git Repository and how they are different.
A repository is nothing but a project's folder and we can also imagine it as just a directory. It can be anything,
- A java project or
- A python project or
- A directory with some documents or
- A web project which contains HTML, JavaScript & CSS files.
What is a GIT Repository?
The definition as per GitHub is
A repository is the most basic element of GitHub. They're easiest to imagine as a project's folder. A repository contains all of the project files (including documentation), and stores each file's revision history. Repositories can have multiple collaborators and can be either public or private.
If you want to know more about version control read Version Control
There are 2 ways we can create a Git Repository
- Create a project directory and convert it into a Git repository.
- Clone an existing repository from a Git server such as GitHub or GitLab or private corporate GitHub.
How to convert an existing project directory into Git Repo?
git init
How to Clone an Existing Repository?
- The repository exists on a public GIT server ex: GitHub (https://github.com/) and you want to contribute.
- You are working in a corporate company and your team has to collaborate and contribute. Every corporate maintains its own GIT server that hosts all projects. Hence you need to clone it and contribute.
git clone <url>
for example, if you want to clone TheBackendPro, you can do so like below:
git clone https://github.com/ulasalasreenath/TheBackendPro
This just pulls all the data from the remote repository and creates a new directory named TheBackendPro & initializes a .git directory inside it.
The cloned repo looks like the one below.
Conclusion:
In this tutorial, we understood what is Git repository and how it differs from a normal repository and also saw how to initialize a repository locally and clone a repository from a remote Git server.