Git:仅忽略文件夹的内容

标签 git github gitignore

我使用以下 .gitignore 文件(全局):

.idea
.svn
/media/covers/*
/media/tmp/*
/media/cache/*
/bin
/include
/lib
/local
*.log
*.pot
*.pyc
local_settings.py

所以在 media/covers, media/tmp, media/cache 我想忽略所有文件和文件夹,但不是这个目录他们自己。此 .gitignore 文件忽略 media/coversmedia/tmpmedia/cache 目录,我该如何修复它?

TIA!

最佳答案

将 .gitignore 文件添加到您要保留的目录。在该目录中放置

*

现在当你执行 git status 时,你会看到内容没有显示为被跟踪,只有 .gitignore 文件。由于 .gitignore 文件在目录中,这意味着将跟踪目录,但不会跟踪其他内容。

关于Git:仅忽略文件夹的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12515576/

相关文章:

iphone - iPhone (Xcode) 项目的 .gitignore 的 'standard' 内容是什么?

python - 为 Django 网站创建 .gitignore 文件

没有自己文件夹的git子模块

git - 阻止用户推送到公共(public)存储库 GitHub

git - 在裸 git-svn 中跟踪一个分支

azure - SvelteKit 应用程序未在 Azure Web Static App 中上传

git - 为现有的 pull 请求做出贡献

Gitignore 不工作

git - `upstream/HEAD -> upstream/master`在 `git branch -r`中是什么意思

git - 无法建立真实性主机 github.com (140.82.xxx.x) - RSA key 指纹是 SHA256 :nThbgh78. ..您确定要继续吗?