Git 忽略陌生事物

标签 git gitignore ignore

在我的存储库中,我有以下目录结构:

/
|-dir1
|    |-file1
|    |-file2
|    |-file3
|-dir2
|    |-file4
|    |-file5.derp
|    |-file6
|-dir3
     |-file7
     |-file8

我的.gitignore文件(位于根目录)如下:

dir2/
!dir2/*.derp

但是,git add 从未找到file5.derp...

我在这里缺少什么?

最佳答案

尝试像这样的 .gitignore:

dir2/*
!dir2/*.derp

每个 gitignore 手册页:http://www.kernel.org/pub/software/scm/git/docs/gitignore.html

If the pattern ends with a slash, it is removed for the purpose of the following description, but it would only find a match with a directory. In other words, foo/ will match a directory foo and paths underneath it, but will not match a regular file or a symbolic link foo (this is consistent with the way how pathspec works in general in git).

我怀疑它忽略了该目录中的所有文件,并且没有达到使用 ! 进行检查的程度。

关于Git 忽略陌生事物,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14858914/

相关文章:

mysql - 打开 gps 跟踪器 git 项目 openshift

git - 只在 git log 修饰中显示 Remote

git - 漂亮的 Git 分支图

sqlite - INSERT或IGNORE INTO不起作用

version-control - 你能在 Perforce 中 "ignore"一个文件吗?

git - 是否有像 svn 一样的 git 忽略命令?

git - 没有任何选项的 'git reset' 命令有什么作用?

angular - 忽略 .gitignore 中名为 npm-debug.log.XXXXXX 的文件

git - 排除 .gitignore 中包含特定文件的目录

git - Git中忽略目录的Unignore子目录