Created
January 21, 2021 12:15
-
-
Save safor/e43ae756a77f230d7e58bf1058d593d4 to your computer and use it in GitHub Desktop.
PowerShell scripts
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
# 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