我只需要控制树上的“debian”子目录:
pkg/.git
pkg/.gitignore
pkg/package1/package1-2.2.1/debian
pkg/package2/package2-1.0/debian
我试过这种.gitignore但是它不起作用:
*
!.gitignore
!*/*/debian
当我跑步时
git add package1 / package1-2.2.1 / debian
git的答案是: 您的.gitignore文件会忽略以下路径: 包1
这是合乎逻辑的。任何帮助将不胜感激!
答案 0 :(得分:2)
您仍然可以添加:
git add -f package1/package1-2.2.1/debian
顺便说一下,您可能不想忽略您的.gitignore
文件,因为您需要知道何时必须对其进行任何更改。如果您不希望在存储库中提交忽略规则,则应使用.git/info/exclude
代替。
答案 1 :(得分:-1)
正如gitignore documentation所说的前缀!
:
An optional prefix ! which negates the pattern; any matching file excluded by a previous pattern will become included again. If a negated pattern matches, this will override lower precedence patterns sources.
也许这意味着你不能使用两个结果!
。尝试删除!.gitignore
一段时间,然后运行git add
。