Skip to content

Instantly share code, notes, and snippets.

@DineshSolanki
Last active April 5, 2024 04:23
Show Gist options
  • Save DineshSolanki/07277c5546e6544f70f7f7b94018562d to your computer and use it in GitHub Desktop.
Save DineshSolanki/07277c5546e6544f70f7f7b94018562d to your computer and use it in GitHub Desktop.
Change remote based on file generated from getRemote.bat
@echo off
setlocal EnableDelayedExpansion
REM Define your multi-repo folder path here:
set "multiRepoDir=path\to\your\multi-repo\folder"
cd /D "%multiRepoDir%"
REM Get the script directory
set "scriptDir=%~dp0"
REM Loop over each line in CSV file
for /F "tokens=1,2 delims=," %%a in ('type "%scriptDir%repos.csv"') do (
REM If the directory exists and is a git repo
if exist "%%a\.git" (
REM Change into the directory
cd "%%a"
REM Change the 'origin' remote to the URL from the CSV file
git remote set-url origin %%b
REM Change back to the root directory
cd /D "%multiRepoDir%"
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment