Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git忽略unignore不工作?_Git_Gitignore - Fatal编程技术网

Git忽略unignore不工作?

Git忽略unignore不工作?,git,gitignore,Git,Gitignore,我已经看到了这个答案: 据我所知,我也在做同样的事情,但git拒绝取消我的目录/文件 这是我的规则。我试图只获取列出的目录/子目录,但是整个公共目录没有显示出来 /public/bootstrap/* !/public/bootstrap/bower_components/bootstrap/dist/* !/public/bootstrap/bower_components/bootstrap/dist/**/* !/public/bootstrap/bower_components/boot

我已经看到了这个答案:

据我所知,我也在做同样的事情,但git拒绝取消我的目录/文件

这是我的规则。我试图只获取列出的目录/子目录,但是整个公共目录没有显示出来

/public/bootstrap/*
!/public/bootstrap/bower_components/bootstrap/dist/*
!/public/bootstrap/bower_components/bootstrap/dist/**/*
!/public/bootstrap/bower_components/bootstrap/less/variables.less

有什么想法吗?

在读了一些书并进行了大量的尝试和错误之后,这个方法很有效:

/public/bootstrap/bower_components/jquery
/public/bootstrap/bower_components/bootstrap/**
!/public/bootstrap/bower_components/bootstrap/dist/
!/public/bootstrap/bower_components/bootstrap/dist/**
!/public/bootstrap/bower_components/bootstrap/less/
!/public/bootstrap/bower_components/bootstrap/less/variables.less
问题似乎是文档中的这一行:“如果文件的父目录被排除,则不可能重新包含该文件。”

这似乎直接与其他答案相矛盾,但对我来说似乎就是这样

在我的测试中,我发现如果你像这样忽略:

/public/bootstrap/*
你不能在每行中取消超过一层的深度

# doesn't work
!/public/bootstrap/bower_components/bootstrap/

# works
!/public/bootstrap/bower_components/
!/public/bootstrap/bower_components/bootstrap/

你可以这样做。“每行不能超过一层深度”这句话是不正确的。你可以参考答案


有助于测试是否正确的命令行:

以下CLI:

git check-ignore -v .idea/bbb.txt .idea/workspace.xml .idea/runConfigurations/Android_Debug___ReactNative.xml android/.idea/aaaa.txt android/.idea/runConfigurations/app.xml
产出如下:

.gitignore:33:**/.idea/**   .idea/bbb.txt
.gitignore:33:**/.idea/**   .idea/workspace.xml
.gitignore:35:!**/.idea/runConfigurations/* .idea/runConfigurations/Android_Debug___ReactNative.xml
.gitignore:33:**/.idea/**   android/.idea/aaaa.txt
.gitignore:35:!**/.idea/runConfigurations/* android/.idea/runConfigurations/app.xml
请注意,第3行和第5行已成功取消忽略(注意“!”符号)

My.gitignore文件:

**/.idea/**
!**/.idea/runConfigurations/
!**/.idea/runConfigurations/*

我只是复制了这个结构和
变量。less
没有被忽略。你确定没有另一个
.gitignore
可能正在捕获它吗?在整个项目文件夹中找到了另一个。gitignore在另一个目录中,其中只有“local”。因此,如果我读对了,第一行忽略所有目录,第二行忽略所有目录,第三行不识别dist中的所有文件和目录?而且,如果我理解正确的话,所有的文件夹现在都被忽略了,但是由于非dist-one中的文件被忽略了,git不会对它们做任何事情吗?
**/.idea/**
!**/.idea/runConfigurations/
!**/.idea/runConfigurations/*