NOTE: 远端仓库名需为 origin
- 新建
onekey_update_git_repo.bat
- 填入以下代码
@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
- 修改
\path\to\git\folders
为需要更新的一堆代码仓库; - 双击执行
onekey_update_git_repo.bat
即可