Tuesday, June 21, 2016

Batch file to clone/pull all GitHub repositories for a given user

@echo off
@setlocal enableextensions enabledelayedexpansion

set gituser=vurdalakov

set curl=curl.exe
set git=git.exe

for /f "delims=" %%a in ('%curl% -i -s https://api.github.com/users/%gituser%/repos') do (
        set line=%%a
        if not !line!==!line:"name"=! (
            set line=!line:"=!
            set line=!line:name:=!
            set line=!line:,=!
            set name=!line: =!
            if exist !name!\nul (
                cd !name!
                %git% pull
                cd ..
            ) else (
                %git% clone https://github.com/%gituser%/!name!.git
            )
        )
    )
)


No comments:

Post a Comment