git - 递归检查是否有 git 签出文件
问题描述
我的所有项目都在一个名为 c:\Projects 的文件夹中。它们都是托管在 Bitbucket 上的 git 项目,我希望遍历所有这些文件夹并检查是否有需要推送的修改文件。有没有办法通过 PowerShell / cmd 行来做到这一点?
谢谢
解决方案
我建议你使用简单的脚本:
$directory = "C:\users\turek\source\my_git_repos";
dir $directory -Directory | ForEach-Object {
cd $_.FullName;
git status;
};
或者,更复杂的版本,它不进入不是 git 存储库的目录:
$directory = "C:\users\turek\source\my_git_repos";
# gets all subdirectories and loops through them
dir $directory -Directory | ForEach-Object {
# if the directory is git repo, then check the status
if ( Test-Path -Path "$($_.FullName)\.git" ) {
# switches directory
cd $_.FullName;
# gets GIT repo status
git status;
}
};
推荐阅读
- c# - 如何使用 C# 将数据插入本地数据库
- java - 如何阻止null打印
- javascript - 不能更正我的 javascript 代码以进行文件大小验证?
- git - git-svn clone:无法连接到存储库
- mysql - 对于 10gb 数据库大小和索引的 1 亿条记录,Mysql 查询仍然很慢
- regex - 如何使用正则表达式排除文本限定符内的分隔符?
- gtk - 如何在 GTK 应用程序中拦截系统按键
- java - java.lang.NullPointerException 更新时发生?
- java - 无法加载我的世界插件:NoClassDefFoundError
- java - 从单向选择转换为多向选择