我的 git 存储库中的所有这些隐藏的('._' 前缀)文件是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10323580/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What are all these hidden ('._' prefixed) files that are in my git repo?
提问by Jakcst
When I do a 'git status' on my directory, it shows a bunch of untracked files that seem to be duplicates. The only difference is that all have a prefix of ._
. For example: One of my untracked files that needs to be added would be... app/assets/stylesheets/categories.css
and another file would display as app/assets/stylesheets/._categories.css
.
当我在我的目录上执行 'git status' 时,它会显示一堆似乎是重复的未跟踪文件。唯一的区别是所有的都有一个前缀._
。例如:我需要添加的未跟踪文件之一将是...app/assets/stylesheets/categories.css
而另一个文件将显示为app/assets/stylesheets/._categories.css
.
Does anyone know what this is all about? There seems to be no good documentation on GitHub.
有谁知道这是怎么回事?GitHub 上似乎没有好的文档。
采纳答案by VonC
As mentioned here:
正如这里提到的:
if for file foo you have another ._foo, and you're on a Mac, the dot-underscore file is where the file resource fork / metadata is kept.
如果对于文件 foo,您有另一个 ._foo,并且您使用的是 Mac,则点下划线文件是保存文件资源分支 / 元数据的位置。
(Described in more details in "DS_Store, dot underscore (._
), resource forks and annoyed Windows users")
(在“ DS_Store,点下划线(._
),资源分叉和恼怒的Windows用户”中有更详细的描述)
The
.DS_Store
is similar to thethumbs.db
file Windows XP makes and is used to store “custom attributes of a folder such as the position of icons or the choice of a background image.”The dot-underscore (
._
) filesare pesky little buggers. It seems that when you use the Finder to transfer files to a non-Mac system–a Windows Server in this case–it splits the file into two parts – the data and the resource forks. When you copy the file back to the Mac, the Finder merges the two bits again. Windows can't use the resource fork, so it's not needed and you can delete it, but it's a lot of hassle having to clean up after others!
该文件
.DS_Store
类似于thumbs.db
Windows XP 制作的文件,用于存储“文件夹的自定义属性,例如图标的位置或背景图像的选择”。该点下划线(
._
)文件是讨厌的小家伙。似乎当您使用 Finder 将文件传输到非 Mac 系统(在本例中为 Windows Server)时,它会将文件分成两部分——数据和资源分支。当您将文件复制回 Mac 时,Finder 会再次合并这两个位。Windows 不能使用资源叉,所以不需要它,你可以删除它,但它要在别人之后清理很麻烦!
See also "Is there any way to prevent a Mac from creating dot underscore files?"
另请参阅“有什么办法可以防止 Mac 创建点下划线文件?”
回答by Alan D.
If you update your global .gitignore
(at C:/Users/user/.gitignore
or wherever your user home directory is), you can add this line:
如果您更新全局.gitignore
(在C:/Users/user/.gitignore
您的用户主目录或任何位置),您可以添加以下行:
._*
It will prevent these from showing up when you do a git status
, and they will not be added via git add -A
.
当您执行 a 时,它将阻止这些显示git status
,并且它们不会通过git add -A
.
This is what I add to mine to prevent various operating systems inserting garbage into our repos.
这是我添加到我的以防止各种操作系统将垃圾插入我们的存储库的内容。
# OS generated files #
######################
.DS_Store?
ehthumbs.db
._*
# Icon?
Thumbs.db
回答by geekosaur
They have nothing to do with git
per se; they're metadata files created by OS X.
它们与git
本身无关;它们是由 OS X 创建的元数据文件。
回答by user3338799
Mac provides command line command which may be available with command line utilities free downloadable from App store . This cleans up ._ files. Command is $dot_clean
Mac 提供命令行命令,可从 App Store 免费下载命令行实用程序。这会清理 ._ 文件。命令是 $dot_clean