Skip to content

Instantly share code, notes, and snippets.

@dwendo
Last active January 8, 2023 20:40
Show Gist options
  • Save dwendo/57227495ad031bbeb54062ee8192a031 to your computer and use it in GitHub Desktop.
Save dwendo/57227495ad031bbeb54062ee8192a031 to your computer and use it in GitHub Desktop.
Clone multiple repos with powershell
# 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
}
}
Copy link

ghost commented Oct 1, 2019

What to put on line 5?

Shouldn't the code auto supply those?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment