Git 使用批处理文件拉取多个存储库

Git Pull for Multiple Repositories with Batch file

我正在尝试 运行 一个批处理文件,

这将转到祖父文件夹,并对其所有子存储库目录执行 git 拉取。出于某种原因,这是行不通的。我怎样才能让它发挥作用?

@ECHO OFF
setlocal
SET parent=%~dp0
ECHO parent=%parent%
FOR %%a IN ("%parent:~0,-1%") DO SET grandparent=%%~dpa
ECHO grandparent=%grandparent%

ECHO %grandparent%

FOR /D %%G in (%grandparent%) Do cd %%G & call git pull & cd ..

TIMEOUT 10

参考如下:

How to git pull for multiple repos on windows?

使用 Windows 10

您可以使用 dir 命令的输出来遍历 %grandparent% 文件夹中的目录,例如:

FOR /F "usebackq tokens=*" %%G in (`dir /A:D-H /B "%grandparent%"`) Do (
    pushd "%grandparent%%%G"
    git pull
    popd
)

希望对您有所帮助。