[英]How to find all directories except the ones under .git directory?
In my git repository I have a small directory structure under the root directory along with a very big directory structure under .git
directory. 在我的git仓库中,我在根目录下有一个小的目录结构,在.git
目录下有一个很大的目录结构。 I would like to use the find
command to get a list of all directories under $(REPO_DIR)
but not including any directory under $(REPO_DIR)/.git
(including). 我想使用find
命令来获取$(REPO_DIR)
下所有目录的列表,但不包括$(REPO_DIR)/.git
(包括)下的任何目录。 I tried something like 我尝试了类似的东西
find $(REPO_DIR) -type d ! -name ".git"
and 和
find $(REPO_DIR) -wholename ".git" -prune -type d
But unfortunately none worked as expected, any suggestions? 但是不幸的是,没有一个按预期工作,有什么建议吗?
Try: 尝试:
find . -type d -not -iwholename '*.git*'
or: 要么:
find . -type d -not -path './.git*'
As an alternative, if you're using bash, you could turn on extglob
mode. 或者,如果您使用的是bash,则可以打开extglob
模式。
shopt -s extglob
This would allow you to do (from within $(REPO_DIR)
): 这将允许您执行操作(在$(REPO_DIR)
):
find !(.git) -type d
See this answer for full details: https://stackoverflow.com/a/217017/24 有关完整的详细信息,请参见以下答案: https : //stackoverflow.com/a/217017/24
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.