batch
@echo off
setlocal
REM 设置 Git 仓库根目录
set "rootDirectory=\path\to\git\folders"
REM 使用 for /r 循环遍历目录树
for /R "%rootDirectory%" %%i in (.) do (
if exist "%%i\.git\" (
echo Found Git repository in folder: %%i
pushd "%%i"
REM 判断当前是否为 PowerShell 环境,如果是则使用 PowerShell 执行命令
powershell -Command "if ($Host.Name -eq 'ConsoleHost') { git pull origin HEAD; git submodule update --init --recursive } else { cmd /c 'git pull origin HEAD & git submodule update --init --recursive' }"
popd
echo Finished updating repository and submodules.
)
)
echo All repositories have been updated.
endlocal