Skip to content

Instantly share code, notes, and snippets.

@daephx
Last active November 12, 2022 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daephx/2af2707113c4ade5fd25ea5387e2bdd9 to your computer and use it in GitHub Desktop.
Save daephx/2af2707113c4ade5fd25ea5387e2bdd9 to your computer and use it in GitHub Desktop.
Generate a list of clone commands for repositories located in some directory.
# Script located in '.vscode\'
# Testing repos are in 'Github\"
$Git = Get-Command git.exe
$Path = "$PSScriptRoot\..\Github\"
$Backup = "$PSScriptRoot\GitList.txt"
$Repos = @()
Get-ChildItem $Path -Directory | ForEach-Object {
if (Test-Path "$($_)\.git") {
$Dir = $_.basename
$GitURL = (& $($Git.source) --git-dir="$($_.fullname)\.git" config remote.origin.url)
$Repos += "git clone $GitURL $Dir"
}
}
$Repos | Out-File $Backup
""
"Backup Complete!"
"Repos Counted: $($Repos.count)"
& notepad $Backup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment