Last active
June 11, 2018 22:38
-
-
Save davetransom/149b7388181fffde71c5821052e35cc7 to your computer and use it in GitHub Desktop.
Searches folders for `.git` subfolder, reports current branch/commit, performs a `git pull`
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($work) | |
# restart PowerShell with -noexit, the same script, and 1 | |
if (!$work) { | |
powershell -noexit -file $MyInvocation.MyCommand.Path 1 | |
return | |
} | |
# source: | |
# https://michael-mckenna.com/update-multiple-git-repositories-on-windows-at-once-using-powershell/ | |
#1. Set up all the environment variables | |
Write-Host "Setting up GitHub Environment" | |
. (Resolve-Path "$env:LOCALAPPDATA\GitHub\shell.ps1") | |
#2. Set up Post-Git | |
Write-Host "Setting up Posh-Git" | |
. (Resolve-Path "$env:github_posh_git\profile.example.ps1") | |
git config --global credential.helper wincred | |
$workingFolder = Get-Location | |
Write-Host -NoNewline "Looking for .git repos in " | |
Write-Host -ForegroundColor Magenta $workingFolder | |
Write-Host "" | |
$repos = gci -Recurse -Depth 2 -Force | ?{ $_.Mode -match "h" -and $_.Name -eq ".git" } | % { $_.Parent } | |
foreach ($repo in $repos) { | |
Push-Location $repo | |
Write-Host -NoNewline -ForegroundColor Cyan $repo.Name | |
Write-Host -ForegroundColor DarkGray " => " | |
git branch -v | |
git pull | |
Pop-Location | |
Write-Host "" | |
} | |
Write-Host "done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment