如何使用git跟踪文件夹结构?

时间:2017-02-26 12:46:06

标签: git gitignore

我尝试使用.gitkeep,但无论我尝试什么,它都无效。

例如,我有一个像这样的文件夹结构:

.
├── a
│   ├── aa
│   │   ├── aaa
│   │   │   ├── .gitkeep
│   │   │   └── test.txt
│   │   ├── .gitkeep
│   │   └── test.txt
│   ├── .gitkeep
│   └── test.txt
├── b
│   ├── bb
│   │   ├── bbb
│   │   │   └── test.txt
│   │   ├── .gitkeep
│   │   └── test.txt
│   └── test.txt
└── .gitignore

我有这样的.gitignore:

*
!a/.gitkeep
!*/.gitkeep
!**/.gitkeep
!.gitignore

这个想法是用.gitkeep保存所有文件夹。令人惊讶的是,此配置不会跟踪任何文件夹。

谁能告诉我为什么这不起作用?

1 个答案:

答案 0 :(得分:1)

  

谁能告诉我为什么这不起作用?

为此,你有git check-ignore -v

其次,it is not possible to re-include a file if a parent directory of that file is excluded

template <typename T> class Tmpl { public: static Tmpl<T>& GlobalInstance() { static Tmpl<T> m_Singleton; return m_Singleton; }; }; 也会忽略文件夹,使其他所有排除规则都没有实际意义。

要仅排除.gitkeep(并忽略保留的文件夹的内容),仅忽略文件,然后将文件夹列入白名单,最后排除(在所有被忽略的文件中)*个文件。

.gitkeep

但如果目标是忽略其中有/** !/**/ !.gitkeep 的文件夹中的任何文件,那么您需要逐个排除任何文件夹:

.gitkeep
相关问题