Skip to content

Instantly share code, notes, and snippets.

@safor
Created January 21, 2021 12:15
Show Gist options
  • Save safor/e43ae756a77f230d7e58bf1058d593d4 to your computer and use it in GitHub Desktop.
Save safor/e43ae756a77f230d7e58bf1058d593d4 to your computer and use it in GitHub Desktop.
PowerShell scripts
# Perform 'git pull' command on main|master branch in all subfolders
Get-ChildItem -directory -force -recurse -depth 1 -filter .git | ForEach-Object {
$cmd = "pull"
$path = $_.Parent.FullName
Push-Location $path
$branch = git rev-parse --abbrev-ref HEAD
if (($branch -eq "main") -or ($branch -eq "master")) {
Write-Host "$path [$branch]> git $cmd" -foregroundColor green
& git $cmd
} else {
Write-Host "$path [$branch]> skip" -foregroundColor yellow
}
Pop-Location
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment