Skip to content

Instantly share code, notes, and snippets.

@chrissainty
Forked from dwendo/cloneRepos.ps1
Created June 14, 2017 10:56
Show Gist options
  • Save chrissainty/a6fe01e36483535bb673408ddd4bc853 to your computer and use it in GitHub Desktop.
Save chrissainty/a6fe01e36483535bb673408ddd4bc853 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
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment