Created
May 12, 2019 01:23
-
-
Save thnk2wn/32d64c4d35b8848fc9225c358cbc620c to your computer and use it in GitHub Desktop.
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
param([string]$checkoutBranch = "develop") | |
function Get-AllRepos ([string]$checkoutBranch = "develop") | |
{ | |
Get-ChildItem -Recurse -Depth 2 -Force | | |
Where-Object { $_.Mode -match "h" -and $_.FullName -like "*\.git" } | | |
ForEach-Object { | |
$dir = Get-Item (Join-Path $_.FullName "../") | |
pushd $dir | |
if ($checkoutBranch) { | |
$branch= &git rev-parse --abbrev-ref HEAD | |
if ($branch -ne $checkoutBranch) { | |
"Checkout out $($checkoutBranch) branch for $($dir.Name)" | |
git checkout $checkoutBranch | |
} | |
} | |
"Pulling $($dir.Name)" | |
git pull -p | |
popd | |
} | |
} | |
Get-AllRepos $checkoutBranch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment