【发布时间】:2021-07-21 14:31:14
【问题描述】:
我的所有项目都在一个名为 c:\Projects 的文件夹中。它们都是托管在 Bitbucket 上的 git 项目,我希望遍历所有这些文件夹并检查是否有需要推送的修改文件。有没有办法通过 PowerShell / cmd 行来做到这一点?
谢谢
【问题讨论】:
-
"...托管在 Bitbucket 上的 GitHub 项目。" :-D
标签: git powershell cmd
我的所有项目都在一个名为 c:\Projects 的文件夹中。它们都是托管在 Bitbucket 上的 git 项目,我希望遍历所有这些文件夹并检查是否有需要推送的修改文件。有没有办法通过 PowerShell / cmd 行来做到这一点?
谢谢
【问题讨论】:
标签: 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;
}
};
【讨论】: