我已经为我的Maven
项目创建了目录结构。
$ tree -a -I .git
.
├── .gitignore
├── README.md
├── pom.xml
└── src
├── main
│ ├── java
│ └── resources
└── test
├── java
└── resources
7 directories, 2 files
现在,我想将结构保留为.git
,这需要在子目录中创建虚拟文件。如何(递归)将空.gitkeep
文件添加到所有空子目录?
以下问题已经讨论了(递归)在子目录中创建空文件的问题,但我希望仅在叶目录中创建文件,而不在任何中间目录中创建文件
来自Ryan Armstrong的博客,这是您的操作方法
find . -type d -empty -not -path "./.git/*" -exec touch {}/.gitkeep \;
find . -type d
(递归)在当前路径下查找目录-empty
过滤掉已经包含某些内容的目录-not -path "./.git/*"
确保没有在.git
目录内创建文件-exec touch {}/.gitkeep \;
.gitkeep
在符合上述条件的每个目录中创建空文件产生的结构看起来像
$ tree -a -I .git
.
├── .gitignore
├── README.md
├── pom.xml
└── src
├── main
│ ├── java
│ │ └── .gitkeep
│ └── resources
│ └── .gitkeep
└── test
├── java
│ └── .gitkeep
└── resources
└── .gitkeep
7 directories, 7 files
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句