What is Repository?
In simple terms, it is the central location in which data is stored or managed. A git repository virtually stores a particular file and allows you to save and access it’s version.
Initializing a Repository
To create a new repository the git init command is used. It is used to covert an existing project to git repository.This is the first and one time command we use during initialization of a new repository. When git init command is executed, .git subdirectory is created.This includes subdirectories for objects,template files etc. An initial head file or new master branch is also created.
git init (directory)
This creates an empty git repository to the specified .
git init command initializes the repository
NOTE:Running git init on a project directory that already contains .git subdirectory will not override existing .git configuration on using git init again.
Only print error and warning messages. All other output is silenced.
It creates a bare repository. It is used when you are collaborating with other developers and need a space to share each other’s changes. For this, a bare repository is created at a central place where everyone can push their changes.
It specifies the directory from which files are copied into the repository.
It sets the access permissions for the new repository. Few Examples are:-
- group (or true): Make repository group- writable.
- all (or world or everybody) :-Same as group, but make the repository readable by all users.
This command is used when the project is already their in the central repository.Like git init, git clone is also one time command.
git clone (repository URL)
git clone is used to create a copy of remote repositories. We pass git clone a repository URL.
Following Images shows the cloning of repository file from github into the local repository directory
It allows you to point to the branch pointed to the cloned repository’s head instead of pointing to newly created head.
It clones the repository at and applies the template form to the newly created local branch.
Other options are –mirror, –bare, –origin and many more.
Summarizing- git init VS git clone
Very simple way to distinguish them is to note the point that git clone is dependent on git init. git clone is used to create a copy of existing repository but git clone itself first calls git init to create new repository.
- Creating Repository in GitHub
- Setup GitLab Repository On Windows 10
- ReactJS | Setting up Development Environment
- PHP | Spreadsheet | Setting a cell value by coordinate
- PHP | Spreadsheet | Setting a date and/or time value in a cell
- JQuery | Setting background-image using CSS property
- Creating Knockout Application along with Setting up Environment in Visual Studio
- Random-Scan Dispaly
- Raster-Scan Displays
- Why Programmers Should Have a Youtube Channel?
- How to insert HTML content into an iFrame using jQuery?
- How to use jQuery in Angular ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nidhi_biet