[英]Git, ignore all files except a few in subdirectories
I've been reading around forever now without a solution that matches my setup. 我一直在无所不包的解决方案中浏览一遍。
I am developing a extra for a cms and I don't want to keep all the cms files in my repo. 我正在为cms开发一个额外的文件,但我不想将所有cms文件保留在我的仓库中。
The files I want to keep are: 我要保留的文件是:
/_build/ [everything inside here]
/core/components/mycomponent/ [everything inside here]
However, I'd like to ignore all the other files in the core
directory as well as other directories. 但是,我想忽略
core
目录以及其他目录中的所有其他文件。
How do I express this in a gitignore? 我该如何在gitignore中表达呢? I've tried with the new syntax from 1.8.2, but I just can't get it to work.
我已经尝试使用1.8.2中的新语法,但是我无法使其正常工作。
Just this simple approach ignores the subdirectories within _build
只是这种简单的方法忽略了
_build
的子目录
*
!.gitignore
!/_build
!/_build/**
If you have a *, you'll drop all files/directories. 如果有*,则将删除所有文件/目录。
If you have /*, you'll drop all directories and files at top level. 如果有/ *,则将所有目录和文件都放在顶层。
It looks like what you really wanted was: 看起来您真正想要的是:
/*
!.gitignore
!/_build
!/core
In the root directory of your project: 在项目的根目录中:
*
!.gitignore
!_build/
!core/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.