.gitignore 和 .gitkeep 有什么区别? [英] What are the differences between .gitignore and .gitkeep?
问题描述
.gitignore
和 .gitkeep
有什么区别?它们是同一个东西但名称不同,还是都具有不同的功能?
What are the differences between .gitignore
and .gitkeep
? Are they the same thing with a different name, or do they both serve a different function?
我似乎找不到关于 .gitkeep
的太多文档.
I don't seem to be able to find much documentation on .gitkeep
.
推荐答案
.gitkeep
没有文档化,因为它不是 Git 的一个特性.
.gitkeep
isn’t documented, because it’s not a feature of Git.
Git 无法添加完全空的目录.想要在 Git 中跟踪空目录的人已经创建了将名为 .gitkeep
的文件放在这些目录中的约定.该文件可以被称为任何东西;Git 没有赋予这个名字任何特殊的意义.
Git cannot add a completely empty directory. People who want to track empty directories in Git have created the convention of putting files called .gitkeep
in these directories. The file could be called anything; Git assigns no special significance to this name.
将 .gitignore
文件添加到空目录以跟踪它们是一种竞争约定,但有些人认为这令人困惑,因为目标是保留空目录,而不是忽略它们;.gitignore
还用于列出 Git 在查找未跟踪文件时应忽略的文件.
There is a competing convention of adding a .gitignore
file to the empty directories to get them tracked, but some people see this as confusing since the goal is to keep the empty directories, not ignore them; .gitignore
is also used to list files that should be ignored by Git when looking for untracked files.
这篇关于.gitignore 和 .gitkeep 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!