如何忽略除两个目录(嵌套)之外的所有内容?

时间:2018-02-27 16:41:45

标签: git gitignore

这是我的根,git安装在那里:

htdocs/
    .git
    xampp
    test
    myweb
    myweb_dependencies
    onOtherProject
    php_info.php
    .gitignore

此处还有.gitignore的内容:

# Ignore everything
*

# But not these files
!myweb
!myweb_dependencies

我想要做的是忽略除了这两个目录之外的所有内容:mywebmyweb_dependencies

问题是:.gitignore的内容显然是错误的,因为它不会跟踪myweb目录中的更改。我该如何解决?

1 个答案:

答案 0 :(得分:1)

应该是这样的:

# Ignore everything
/*
/*/

# But not these files
!/myweb/
!/myweb_dependencies/