.git文件夹不包含什么内容?

时间:2021-09-11 16:57:18

From the git site (emphasis mine):

从git站点(强调我的):

When you run git init in a new or existing directory, Git creates the .git directory, which is where almost everything that Git stores and manipulates is located. If you want to back up or clone your repository, copying this single directory elsewhere gives you nearly everything you need.

当您在新目录或现有目录中运行git init时,Git会创建.git目录,这是Git存储和操作的几乎所有内容所在的目录。如果要备份或克隆存储库,在其他位置复制此单个目录几乎可以为您提供所需的一切。

They sneak "almost" and "nearly" in there without elaborating. What isn't located in the .git directory? If I want to back up or clone my repository, what does copying that single directory elsewhere not give me?

他们在那里偷偷“差点”和“差点”而没有详细说明。什么不在.git目录中?如果我想备份或克隆我的存储库,那么在其他位置复制该单个目录不会给我什么?

3 个解决方案

#1


Git does not record:

Git没有记录:

  • file groups
  • file owners
  • file permissions (other than "is this executable")
  • 文件权限(“这是可执行文件”除外)

  • extended attributes
  • empty folders
  • (anything in .gitignore, but that's probably desired)
  • (.gitignore中的任何内容,但这可能是期望的)

  • gitmodules

Probably this post can provide you more insights

这篇文章可能会为您提供更多见解

#2


You have a couple other .git files that make up your repository outside of the .git folder itself, in particular, you have:

您有一些其他.git文件构成了.git文件夹本身之外的存储库,特别是,您有:

.gitignore # contains the files that you do not want in the repository
.gitmodules # contains the information on submodules

As well if you have a submodule, you will have a plain text file .git that points back to the "real repository directory" - see git Repository Layout Docs

如果你有一个子模块,你将有一个纯文本文件.git指向“真正的存储库目录” - 请参阅git存储库布局文档

#3


Your user/global configuration file is typically in ~/.gitconfig

您的用户/全局配置文件通常位于〜/ .gitconfig中

The system configuration file is typically in $(prefix)/etc/gitconfig

系统配置文件通常位于$(前缀)/ etc / gitconfig中

Submodule information would be stored in the top level of your working directory in a .gitmodules file

子模块信息将存储在.gitmodules文件的工作目录的顶层

Information about ignoring files could come from any number of .gitignore files in your working directory. But it could also come from a excludes file via git config --global core.excludesfile ~/.gitignore_global or similar.

有关忽略文件的信息可能来自工作目录中的任意数量的.gitignore文件。但它也可能来自通过git config --global core.excludesfile~ / .gitignore_global或类似的排除文件。

If you have an alternate object store or a reference repository configured in .git/objects/info/alternates, then you will have external object dependencies.

如果在.git / objects / info / alternates中配置了备用对象库或引用存储库,则将具有外部对象依赖性。

#1


Git does not record:

Git没有记录:

  • file groups
  • file owners
  • file permissions (other than "is this executable")
  • 文件权限(“这是可执行文件”除外)

  • extended attributes
  • empty folders
  • (anything in .gitignore, but that's probably desired)
  • (.gitignore中的任何内容,但这可能是期望的)

  • gitmodules

Probably this post can provide you more insights

这篇文章可能会为您提供更多见解

#2


You have a couple other .git files that make up your repository outside of the .git folder itself, in particular, you have:

您有一些其他.git文件构成了.git文件夹本身之外的存储库,特别是,您有:

.gitignore # contains the files that you do not want in the repository
.gitmodules # contains the information on submodules

As well if you have a submodule, you will have a plain text file .git that points back to the "real repository directory" - see git Repository Layout Docs

如果你有一个子模块,你将有一个纯文本文件.git指向“真正的存储库目录” - 请参阅git存储库布局文档

#3


Your user/global configuration file is typically in ~/.gitconfig

您的用户/全局配置文件通常位于〜/ .gitconfig中

The system configuration file is typically in $(prefix)/etc/gitconfig

系统配置文件通常位于$(前缀)/ etc / gitconfig中

Submodule information would be stored in the top level of your working directory in a .gitmodules file

子模块信息将存储在.gitmodules文件的工作目录的顶层

Information about ignoring files could come from any number of .gitignore files in your working directory. But it could also come from a excludes file via git config --global core.excludesfile ~/.gitignore_global or similar.

有关忽略文件的信息可能来自工作目录中的任意数量的.gitignore文件。但它也可能来自通过git config --global core.excludesfile~ / .gitignore_global或类似的排除文件。

If you have an alternate object store or a reference repository configured in .git/objects/info/alternates, then you will have external object dependencies.

如果在.git / objects / info / alternates中配置了备用对象库或引用存储库,则将具有外部对象依赖性。