Stat-R
Stat-R

Reputation: 5270

Update all git repos in a folder in windows

This answer is for linux command line. I need the same for Windows command line. I created the following using this, but my code does not work.

for /D /r %i in (*.*) do (cd %i && echo %i && git pull && cd ..)

Update

From @SevenEleven's answer and @kostix's comment the following worked.

for /D %%i in (.\*) do (cd "%%i" && git pull && cd..)

or

for /D %%i in (*) do (cd "%%i" & git pull && cd..)

Upvotes: 1

Views: 2665

Answers (1)

SevenEleven
SevenEleven

Reputation: 2474

This should do the job:

for /D %%i in (.\*) do (cd %%i && echo %%i && git pull && cd ..)

This script searches the subdirectories of the current directory (for /D %%i in (.\*)). It changes to every directory found (cd %%i), writes its name to console (echo %%i) and executes git pull

/r does search all subdirectories too. Since you don't want to search your projects subdirectories, that is not needed. If you search an absolute path, you can get rid of the cd ..:

Upvotes: 6

Related Questions