Last active
January 8, 2023 20:40
-
-
Save dwendo/57227495ad031bbeb54062ee8192a031 to your computer and use it in GitHub Desktop.
Clone multiple repos with powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import multiple remote git repositories to local Source dir | |
param ( | |
[string]$localFolder = "c:\Source\", | |
[array]$repos = @("myRepo", "repo1") | |
) | |
$repoLocation = "https://github.com/" | |
# for each repo found remotely, check if it exists locally | |
# if dir exists, skip, if not, clone the remote git repo into it | |
foreach ($gitRepo in $repos) { | |
If (Test-Path $localFolder\$gitRepo) { | |
echo "repo $gitRepo already exists" | |
} | |
Else { | |
echo "git clone $repoLocation$gitRepo $localFolder\$gitRepo" | |
git clone $repoLocation$gitRepo $localFolder\$gitRepo | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What to put on line 5?
Shouldn't the code auto supply those?