Gitiginore 除了带有 .rst 扩展名的文件之外的所有文件?
gitignore 中的 ** 和 * 有点令人困惑。这是我在 .gitignore 中的内容:
*
!*.rst
这适用于根目录中的所有 *.rst 文件。子目录中的 .rst 文件怎么样?
我尝试过
*
!*.rst
!**/*.rst
但这并没有改变任何东西。
The ** and * in gitignore are a bit confusing. Here is what I have in .gitignore:
*
!*.rst
This works for all *.rst files in the root directory. What about .rst files in subdirectories?
I tried
*
!*.rst
!**/*.rst
But this does not change anything.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 .gitignore 中尝试以下操作,
这样可以告诉 git 不要忽略子目录。
Try the following in your .gitignore
This way you tell git to not ignore subdirectories.
如果您阅读此SO答案,您会意识到Git 忽略文件的方式取决于系统。
那么您使用什么操作系统和 Git 发行版(Unix 或 Windows 上的 Msysgit)?
因为在 Windows 上,“
**
”不能很好地工作(如果有的话)。另外,请确保在 .gitignore 文件中声明 *.rst 文件之前,它们尚未添加到缓存中。在 .gitignore 按预期工作之前,需要将它们从缓存中删除(并提交清除的缓存)(另请参阅此 博客文章)
If you read this SO answer, you will realize the way Git ignore files is system-dependent.
So what OS and Git distro are you using (Unix, or Msysgit on Windows)?
Because on Windows, the '
**
' does not work very well (if at all).Plus, make sure your *.rst files were not already added to the cache before you declared them in the .gitignore file. They would need to be removed from the cache (and the purged cache committed) before .gitignore works as intended (see also this blog post)