What does exactly mean by the term repository in git?

混江龙づ霸主 提交于 2019-12-24 19:25:07

问题


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?


回答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.




回答2:


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.



来源:https://stackoverflow.com/questions/47727820/what-does-exactly-mean-by-the-term-repository-in-git

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!