Skip to content

Instantly share code, notes, and snippets.

@aaronhoffman
Created February 9, 2018 20:07
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 aaronhoffman/ce9152052b3f830152925f5d6077b692 to your computer and use it in GitHub Desktop.
Save aaronhoffman/ce9152052b3f830152925f5d6077b692 to your computer and use it in GitHub Desktop.
Given a path, find all git repos and perform a git fetch
param (
[string]$path = "c:\dev\"
)
Write-Output "Recurse in $path for hidden .git folders..."
$gitdirs = Get-ChildItem -Recurse -Path $path -Force -Filter ".git"
Write-Output "Found: $($gitdirs.Length) repos"
$cwd = (Get-Item -Path ".\" -Verbose).FullName
foreach ($gitdir in $gitdirs)
{
Write-Output "Fetch all for $($gitdir.Parent.FullName)"
Set-Location $gitdir.Parent.FullName
&git fetch --all
}
Set-Location $cwd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment