我怎样才能让git只列出文件夹中的跟踪目录? [英] How can I make git list only the tracked directories in a folder?

查看:140
本文介绍了我怎样才能让git只列出文件夹中的跟踪目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 git list-files 可以给我所跟踪的目录和文件。有没有类似命令:

  git list-directories 

或类似的东西,只列出跟踪的非空非递归目录名称?

解决方案我认为这会给你你想要的:



git ls-files | xargs -n 1 dirname | uniq



因此,将 git ls-files 的输出和pipe dirname ,然后 uniq 结果。这似乎在本地为我工作。


Using git list-files gives me the directories and the files tracked within. Is there a command like:

git list-directories

or something similar that lists only the tracked non-empty non-recursive directory names?

解决方案

I think this will give you what you want:

git ls-files | xargs -n 1 dirname | uniq

So, take the output of git ls-files and pipe that into dirname, then uniq the results. This appears to work locally for me.

这篇关于我怎样才能让git只列出文件夹中的跟踪目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆