Git忽略unignore不工作?

时间:2014-10-22 19:16:48

标签: git gitignore

我看过这个答案:Unignore subdirectories of ignored directories in Git

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

这些是我的规则。我正在尝试获取列出的目录/子目录,但整个公共目录没有显示。

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

有什么想法吗?

3 个答案:

答案 0 :(得分:8)

您可以按照以下方式执行此操作。句子"You can't unignore more than one level deep per line"不正确。您可以参考答案here

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

答案 1 :(得分:4)

在做了一些阅读和大量试验和错误后,这有效:

/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/

答案 2 :(得分:1)

如果你做对了,可以帮助测试的命令行:https://git-scm.com/docs/git-check-ignore

以下CLI:

.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

输出以下内容:

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

注意第3行和第5行未被忽略(请注意"!"签名)。

我的.gitignore文件:

{{1}}
相关问题