Git 忽略除子文件夹之外的所有内容
我搜索了其他问题,但找不到适合我的项目的可行解决方案。 拥有一个 Magento 项目,我想排除除此之外的所有内容:
/app/design/frontend/default/theme_name # and obviously all subfolders
/skin/frontend/default/theme_name # and all subfolders
我尝试了很多组合,但没有运气。目前我被这个 .gitignore 文件困住了:
*
!/app/
!/app/*
app/*
!/app/design/
!/app/design/*
但它不能在设计文件夹下递归地工作。它仅在我创建的设计文件夹中添加了一个测试文件。
I searched through other questions but can't find a working solution for my project.
Having a Magento project, I want to exclude everything except this:
/app/design/frontend/default/theme_name # and obviously all subfolders
/skin/frontend/default/theme_name # and all subfolders
I've tried a lot of combinations but without luck. Currently I'm stuck with this .gitignore file:
*
!/app/
!/app/*
app/*
!/app/design/
!/app/design/*
But it doesn't work recursively below the design folder. It only added a test file inside the design folder that I created.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在这里看看我的答案: 无法理解 gitignore 如何忽略文件夹
引用:
另外,您应该考虑将
.gitignore
放在子目录而不是根级别,因为如果您必须从根.gitignore
转到子目录级别,它会变得非常复杂由于上面的解释,对于每个级别,您都必须忽略文件夹,然后忽略内容等等。Look at my answer here: Can't understand how gitignore ignores the folders
Quoting from that:
Also, you should look at having
.gitignore
at subdirectory rather than at root level only as it becomes pretty complex if you have to go to the subdirectory level from the root.gitignore
because of the explanation above, whereby for each level, you have to unignore the folder and then ignore the contents and so on.在这里做了一些研究。对我有用的是:
通过这个
/directory
的子目录可以正确跟踪。奇怪的是,它不适用于第一行上的仅/
或仅*
- 我不知道为什么。Did some research here. What worked for me was:
With this subdirectories of
/directory
were tracked correctly. Curiously it doesn't work with either only/
or only*
on the first line - I am not sure why.说明:
我通常对子文件夹执行此操作,所以我不知道第一行是否有效。
Explaination:
I usually do this to sub-folders, so I don't know if the first line will work.