.gitignore 中 tmp/**/* 忽略什么?

发布于 2024-12-02 01:54:52 字数 422 浏览 4 评论 0原文

在我的 .gitignore 文件中,

tmp/**/*

它排除了哪些文件?它会排除所有 tmp 及其下的文件/文件夹吗?

我的另一个问题是,这与下面的有什么不同吗?

tmp/*

编辑:

我问的原因是因为我有这个

.vimbackup/**/*

,但它不会忽略像 .vimbackup/.somebackup~ 这样的文件

,但是,如果我

.vimbackup/*

这样做,就会忽略文件 .vimbackup/.somebackup ~ 对我来说似乎有点倒退

In my .gitignore file I have

tmp/**/*

What files does it exclude? Will it exclude all tmp and files/folders under it?

My other question is, is this different from the following?

tmp/*

Edit:

Reason I ask is because I a have this

.vimbackup/**/*

but it is NOT ignoring a file like .vimbackup/.somebackup~

However, if I do

.vimbackup/*

it DOES ignore the file .vimbackup/.somebackup~ Seems kinda backwards to me

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅唱々樱花落 2024-12-09 01:54:52

通常该符号意味着包含 tmp 中的任何子目录。然后这些目录中的文件也包含在内(因为有额外的 /*),

它也递归地包含子目录。所以 tmp/billy/bob/* 以及 tmp/banjo/* 等都会被忽略......

话虽这么说。我从来没有使用过 git...所以我可能是错的。但许多 IDE 和版本控制程序都使用这种表示法。

刚刚注意到你的第二个问题。是的,它与 tmp/* 不同,后者会忽略所有文件,但不会忽略目录及其各自的文件。

Usually that notation means to include any subdirectory within tmp. And then files within those directories too (because of the additional /*)

It includes sub-directories recursively as well. So tmp/billy/bob/* will be ignored as well as tmp/banjo/* and so on...

That being said. I've never used git... so I could be wrong. But many IDEs and version control programs use that notation.

Just noticed your second question. Yes it is different from just tmp/* Which will ignore all files, but not directories and their respective files.

情绪失控 2024-12-09 01:54:52

如果文件已经提交,那么 git 会记住它,直到您明确让 git 将其从索引/暂存区域中删除。即使您更新了 .gitignore 文件也是如此,这可能会造成混乱。

查看 git rm来删除之前提交的文件,您现在通过 .gitignore 文件忽略该文件(请参阅许多 SO 问答)。

If a file has already been committed then git will remember it until you explicitly get git to remove it from the index/staging area. This is even if you update the .gitignore file, which can be confusing.

look at git rm <file> for removing a file that has been previously committed that you are now ignoring via the .gitignore file (see many SO Q&As).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文