0

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?

Mouloud85
  • 3,826
  • 5
  • 22
  • 42
  • If speaking of the remote repository, then conceptually you only need to view it as the place where the actual branches and commits live. Locally, yes you could say that the `.git` folder is the repository, though I usually see this term being used in the remote sense. – Tim Biegeleisen Dec 09 '17 at 11:00

2 Answers2

1

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.

Ram Iyer
  • 319
  • 1
  • 4
  • 14
1

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.

ElpieKay
  • 27,194
  • 6
  • 32
  • 53