Skip to content

Instantly share code, notes, and snippets.

@danbarratt
Created February 1, 2017 09:21
Show Gist options
  • Save danbarratt/4630e027c5167bf29279d242d13fabed to your computer and use it in GitHub Desktop.
Save danbarratt/4630e027c5167bf29279d242d13fabed to your computer and use it in GitHub Desktop.
Run 'git gc' in each subdirectory
$originalWorkingDir = Get-Location;
$subDirectories = dir -Directory;
Foreach ($subDirectory in $subDirectories)
{
$projectDir = Join-Path $originalWorkingDir $subDirectory;
$gitDir = Join-Path $projectDir '.git'
if (Test-Path $gitDir -PathType Container)
{
Write-Host "$projectDir> $Env:ProgramFiles\Git\bin\git.exe gc";
Set-Location -Path $projectDir;
Start-Process "$Env:ProgramFiles\Git\bin\git.exe" -ArgumentList 'gc' -Wait;
}
}
Set-Location -Path $originalWorkingDir;
Write-Host 'All Done!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment