Skip to content

Instantly share code, notes, and snippets.

@SirkleZero
Created September 25, 2012 22:40
Show Gist options
  • Save SirkleZero/3784905 to your computer and use it in GitHub Desktop.
Save SirkleZero/3784905 to your computer and use it in GitHub Desktop.
This powershell script will enumerate the Git projects in a parent directory, perform a fetch on each remote and then print out the status of the repo.
$global:GitAllSettings = New-Object PSObject -Property @{
FolderForegroundColor = [ConsoleColor]::Cyan
}
function git-all()
{
$s = $global:GitAllSettings
dir -r -i .git -fo | % {
pushd $_.fullname
cd ..
write-host -fore $s.FolderForegroundColor (get-location).Path
git-fetchall
popd
}
}
function git-fetchall()
{
$remotes = git remote
if($remotes){
$remotes | foreach {
Write-Host 'Fetching from' $_
git fetch $_
}
}else{
Write-Host 'No remotes for this repository'
}
git status
}
[System.Reflection.Assembly]::LoadWithPartialName("System.Diagnostics")
$sw = new-object system.diagnostics.stopwatch
$sw.Start()
git-all
$sw.Stop()
Write-Host "Completed in " $sw.Elapsed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment