user9059272
user9059272

Reputation:

What does exactly mean by the term repository in git?

I'm trying to learn git.

I read few tutorials. Everywhere I got confused with the actual meaning of this term called 'Repository'.

See the below definitions :

A repository contains a directory named .git, where git keeps all of its metadata for the repository. The content of the .git directory are private to git.

So, my question is whether the directory which contains entire project (i.e. all the files of my project) along with the .git directory (usually it's hidden by default) is called the Repository of only the .git folder present within my project folder is called the Repository?

Upvotes: 2

Views: 759

Answers (2)

ElpieKay
ElpieKay

Reputation: 30966

I believe both are right.

In Pro Git, it says, "This leads us to the three main sections of a Git project: the Git directory, the working tree, and the staging area." There is a picture which says ".git directory (Repository)". From this we can say a repository is .git, where Git stores the metadata and object database for your project.

However, there is evidence that proves a repository includes more than .git. A Git repository can be either bare or non-bare. What is a bare repository? It is a repository that doesn’t contain a working directory. So a non-bare repository contains a working directory. Besides, let's take a look at a Git submodule. What is a submodule? A submodule is a repository embedded inside another repository. A bare repository can't be added as a submodule. And the operation to add a submodule must be in a work tree of the super project.

As to the difference between a working directory and a work tree, it's another story. There are some answers.

Upvotes: 1

Ram Iyer
Ram Iyer

Reputation: 319

Think of this in this way: The folder containing your project files (all the code) is the code repository. The .git folder that contains the Git metadata is the Git repository. The Git repository corresponds to the contents of the code repository.

In general, when someone says "Repository", it usually means the code repository (including the .git folder, if the code base is version-controlled). When "Repository" is said in terms of Git, it technically means the .git folder and its contents.

Upvotes: 1

Related Questions