What is the difference between "git init" and "git init --bare"?

13

The question is very simple indeed:

What is the difference between these two commands, git init and git init --bare ?

What is this --bare ?

    
asked by anonymous 11.08.2015 / 18:43

2 answers

15

With the command git init --bare you are creating a repository that is pushable . Generally bare repositories are created on the server and are considered repositories for storage, in contrast to the repositories that go on the developers' machines that would be the development repositories, created with the git init command (without --bare ). / p>

Although the GIT is a distributed versioning control system, it is very common that there is a central repository that facilitates the exchange of information between the developers, avoiding the need for the developers' computers to communicate directly with each other. >

An illustration of the above paragraph:

Inaddition,barerepositoriesdonothaveworkingdirectory,makingitimpossibletoeditandcommitfilesinthisrepository.

BelowisanimageofthedeveloperGITrepositoriesstream(notbare):

Source: Atlassian - Setting up a repository

    
11.08.2015 / 18:55
6

What it is:

When you start a repository such as bare , you will not be able to edit files (git add) and commit (git commit), as it does not have a working tree . You should upgrade a bare repository using git push .

When it is used:

You initialize a repository as bare when you want it to be the central repository.

    
11.08.2015 / 19:01