- 1 year ago
How to do git pull for all sub-directories in a folder?(In Windows )
To perform a git pull
operation for all subdirectories in a folder on Windows, you can use a simple batch script. Here's an example:
Create a new text file with a
.bat
extension, such asgit_pull_all.bat
.Open the file in a text editor and add the following code:
batch@echo off
setlocal enabledelayedexpansion
set "base_dir=C:\path\to\parent_folder"
for /d %%D in ("%base_dir%\*") do (
if exist "%%D\.git" (
echo Updating repository: %%D
cd /d "%%D"
git pull
echo.
)
)
endlocal
Replace
C:\path\to\parent_folder
with the actual path to the parent folder containing your subdirectories.Save the file and close the text editor.
Double-click the
.bat
file to run it. It will iterate through all subdirectories in the specified parent folder, check if a.git
folder exists (indicating it's a Git repository), and perform agit pull
operation if a repository is found.
The script uses a for
loop with the /d
option to iterate through the subdirectories of the specified parent folder. It checks for the presence of a .git
folder in each subdirectory using the exist
command. If a .git
folder is found, it changes the directory to that subdirectory and performs a git pull
operation.
Note that this script assumes that you have Git installed and added to your system's PATH environment variable.
By running this batch script, you can conveniently perform a git pull
operation on all Git repositories within the specified parent folder and its subdirectories.