Last active
November 12, 2022 14:15
-
-
Save daephx/2af2707113c4ade5fd25ea5387e2bdd9 to your computer and use it in GitHub Desktop.
Generate a list of clone commands for repositories located in some directory.
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
# 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