Skip to content

Instantly share code, notes, and snippets.

@braddevans
Created February 3, 2021 12:56
Show Gist options
  • Save braddevans/74ddd489d821e23e4940d04af531dcd3 to your computer and use it in GitHub Desktop.
Save braddevans/74ddd489d821e23e4940d04af531dcd3 to your computer and use it in GitHub Desktop.
Git pull All in Current Directory
Get-ChildItem */* |
where {$_.name -eq "README.md"} |
foreach {
cd $_.DirectoryName;
$folderName = pwd | Select-Object | %{$_.ProviderPath.Split("\")[-1]}
$BranchName = git rev-parse --abbrev-ref HEAD
$CurrentBranchRevision = git log -1 --pretty=format:%h
$NewestBranchRevision = git log -n 1 origin/$BranchName --pretty=format:%h
Write-Host "`n-===============================================-"
Write-Host "- -"
Write-Host "- " -ForegroundColor White -NoNewline;
Write-Host "Processing project: " -foreground DarkYellow -NoNewline;
Write-Host $folderName -foreground Green;
Write-Host "- -"
Write-Host "-===============================================-"
Write-Host "- -"
Write-Host "Current Branch: " -ForegroundColor White -NoNewline;
Write-Host $BranchName -ForegroundColor Green;
Write-Host "-" -ForegroundColor White;
Write-Host "Current Revision Hash: (" -ForegroundColor White -NoNewline;
Write-Host $CurrentBranchRevision -ForegroundColor Green -NoNewline;
Write-Host ")" -ForegroundColor White;
Write-Host "-" -ForegroundColor White;
Write-Host "Latest Revision Hash: (" -ForegroundColor White -NoNewline;
Write-Host $NewestBranchRevision -ForegroundColor Green -NoNewline;
Write-Host ")" -ForegroundColor White;
Write-Host "-" -ForegroundColor White;
Write-Host "Branches: " -ForegroundColor White -NoNewline;
Write-Host "[ " -foreground DarkYellow;
git branch -r
Write-Host "] " -foreground DarkYellow;
Write-Host "- -"
Write-Host "-===============================================-`n"
Write-Host "Pulling Latest Git:"$NewestBranchRevision
git pull;
cd ..
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment