在.gitignore中使用`* .sh`但允许跟踪'A / B / C.sh`

时间:2018-01-09 13:17:12

标签: git gitignore

注意:我已经删除了这个问题,因为使用!run.sh对我来说很有用,我也希望在ansible / files中允许任何文件。(我将来可能添加的任何文件) 。)我发现的其他解决方案对我来说不起作用。

我想要从我的存储库中排除所有.sh个文件,为此我使用了*.sh,但我希望在ansible/files中包含任何文件 目前,我的.gitignore文件如下所示:

# Ignore python environment
venv/

# Ignore .pyc files
*.pyc

# Ignore .log Files
*.log

# Ignore any __pycache__
__pycache__/

# Ignore .sh files
*.sh

# Allow any `.sh` file(s) in ansible/files folder
!/ansible/files/*.sh

# Allow any file(s) in ansible/files folder
!/ansible/files/*

但这不起作用,ansible/files/run.sh是一个存在但未被跟踪的文件。 问题:为什么.gitignore忽略!/ansible/files/*.sh& !/ansible/files/*;如何允许跟踪该文件夹中的任何文件?

注意:我已经删除了这个问题,因为使用!run.sh对我有用,我希望允许ansible/files中的任何文件。(我将来可能添加的任何文件。 ) 我发现的其他解决方案对我来说并不适用。

1 个答案:

答案 0 :(得分:1)

您可能错过了路径前面的通配符。这只是一个假设,但我怀疑你的目标是"stores" : [ { value: 1, label: 'lopd', }, { value: 2, label: 'abc' } ]

试试这个:

(root)/ansible

此外,您必须将# Allow any `.sh` file(s) in ansible/files folder !*/ansible/files/*.sh # Allow any file(s) in ansible/files folder !*/ansible/files/* 的规则更改为以下内容:

*.sh