What is Git Repository? How to Create Git Repository?
Table of Contents
- What is Git Repository?
- Important Git Repository Commands
- How to Create Git Repository?
- How to Add Git Repository to Existing Project?
What is Git Repository?
Repositories are an important part of Git. If you have understood what is Git and why it is used, read about the Git Version Control System, and now want to understand exactly what is a Git repository and how to create it, then it’s time to get started.
A Git repository is a digital location where you can save your project. It enables you to keep multiple variations of the code so you can go back to them whenever you need them.
The repository in Git also allows you to track changes that have happened over time to your project.
This is extremely helpful when you are working on a team and need to see who made a change and when that change was made.
Important Git Repository Commands
In the beginning, a Git repository can be very confusing because it has so many terms related to it. The most important terms are git, clone, and push.
A brief explanation of these terms will help you understand how the Git repository works:
git is a command that allows you to manage your files and create backups.
clone command is used for downloading a copy of your project from someone else who has already created it.
push command is used for sending files from your local computer to another computer that is connected to yours through the network (this process occurs only if you have permission to do it).
How to Create Git Repository?
The Git init command is used to create a new repository. init is a one-time command used to add a new repository in Git.
This operation will make a new directory in your current directory .Git subfolder. It will also result in the creation of a new main branch.
How to Add Git Repository to Existing Project?
As part of our complete Git Tutorial for Beginners, we have also covered the way to add the repository to your existing project.
This example assumes that you already have a project folder in which you want to create a Git repository. After that, you'll add cd to the root project folder and run the Git init command.
When you point Git init to an existing project directory, it will run the same initialization configuration as before, but only for that project directory.
git init /project/directory/project/directory/project/directory/project/directory