Skip to content

Instantly share code, notes, and snippets.

@burtonr
Last active October 21, 2019 20:18
Show Gist options
  • Save burtonr/e56349380ebce03a8fe7762d8646641c to your computer and use it in GitHub Desktop.
Save burtonr/e56349380ebce03a8fe7762d8646641c to your computer and use it in GitHub Desktop.
Work in Progress Directory Scan
<#
.DESCRIPTION
Script to recursively run `git status` on all sub-directories in order to find out
if, or where, you have uncommited files. AKA: Work-in-progress.
The only pre-requisite is that git is installed.
This will work on any operating system with Powershell installed
#>
$ErrorActionPreference = 'SilentlyContinue' # Silence the "not a git repository" errors
$repoDir = "C:\Users\<your username>\source\repos"
$repos = Get-ChildItem $repoDir
ForEach($r in $repos) {
Write-Host "Checking $r" -ForegroundColor Green
Set-Location $repoDir\$r
$status = git status
if(!$status.Contains('nothing to commit, working tree clean')) {
if($status -like "*modified*") {
Write-Host "Unstaged changes found:" -ForegroundColor Red
git status -uno
}
else {
Write-Host "Untracked files found." -ForegroundColor Yellow
}
}
Set-Location $PSScriptRoot
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment