0

I am trying to run a batch file,

which will go to grandparent folder, and do git pull for all its child repository directories. For some reason, this is not working. How can I get this functioning?

@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

Using following as reference:

How to git pull for multiple repos on windows?

Using Windows 10

oguz ismail
  • 1
  • 16
  • 47
  • 69

1 Answers1

0

You could use the output of dir command to iterate over the directories in your %grandparent% folder, something like:

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

Hope it helps.

dcg
  • 4,187
  • 1
  • 18
  • 32