Git状态-仅列出具有更改的直接子文件夹,而不列出内部文件 [英] Git Status - List only the direct subfolders with changes, not inner files
问题描述
我喜欢使用Git来组织版本控制并在Wordpress中备份我的所有Web文件.
I love using Git to organize version control and backup all my web files in Wordpress.
更新插件后,我只想使用git status
来获取直接子文件夹上的更改列表.通常,如果执行git status,将需要很长的更改时间,包括每个子文件夹的内部.
我想要的是通过plugins
目录中的更改将结果限制在子文件夹中.
After updating plugins, I'd like to get the list of changes only on the direct subfolder by using git status
. Typically if doing git status will a very long line of changes including the inner of each subfolder.
what I'd like is to limit the result to the subfolders with the changes inside the plugins
directory.
例如,以下git命令:
For example, this git command:
git status project_folder/wp-content/plugins
git status project_folder/wp-content/plugins
将导致:
plugins/wpml-translation-management/classes/translation-basket/
plugins/wpml-translation-management/classes/translation-dashboard/
plugins/acfml/assets/
plugins/acfml/classes/class-wpml-acf-attachments.php
plugins/wordpress-seo/js/dist/commons-921.min.js
plugins/wordpress-seo/js/dist/components-921.min.js
实际上,git命令会产生一长串的行,如屏幕截图所示:
Actually, the git command will make a really long list of lines like on the screenshot:
我想知道的是git命令仅输出:
What I would love to know is the git command to output only:
plugins/wpml-translation-management/
plugins/acfml/
plugins/wordpress-seo/
命令如下:
git status project_folder/wp-content/plugins-{display_only_direct_subfolders_with_changes}
git status project_folder/wp-content/plugins --{display_only_direct_subfolders_with_changes}
推荐答案
尝试一下:
git status --porcelain | awk '{print $2}' | xargs -n 1 dirname | uniq
awk '{print $2}'
从列表中获取文件名
xargs -n 1 dirname
从完整路径中提取目录
uniq
仅显示唯一目录
uniq
可能会慢一点
这篇关于Git状态-仅列出具有更改的直接子文件夹,而不列出内部文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!