这里有一个快速“东经脏PowerShell脚本:
$fn = $env:temp\gitStat.txt
$dir = dir $pwd | ?{$_.PSISContainer}
$start = $pwd
foreach ($d in $dir) {
cd $d
if(Test-Path $fn) {
Remove-Item $fn
}
& git status | Out-File $fn
$ss = Select-String -Path $fn -SimpleMatch "Changes not staged for commit"
if($ss -ne $null) {
$msg = [string]::Format("{0} has modified files", $pwd)
Write-Host $msg
}
$ss = Select-String -Path $fn -SimpleMatch "Untracked files"
if($ss -ne $null) {
$msg = [string]::Format("{0} has untracked files", $pwd)
Write-Host $msg
}
$ss = Select-String -Path $fn -SimpleMatch "Changes to be committed"
if($ss -ne $null) {
$msg = [string]::Format("{0} has staged files", $pwd)
Write-Host $msg
}
cd $start
}
这里有一个批处理文件,我写信给下JPSoft的tcc.exe命令shell中运行。它可能可以适应cmd.exe或PowerShell。
@echo off
: Because this needs %_cwd, it must be used with TCC.exe
@if "%_cmdproc"=="TCC" (goto OK)
:testTCCLE
@if NOT "%_cmdproc"=="TCCLE" (goto wrongShell)
:OK
global /i /q /s4 (if exist .git\ echo === %_cwd === && git status)
goto xit
:wrongShell
echo TCC/TCCLE required.
:xit
这显示了每个git目录的状态;我一直在研究一个版本,只显示没有提交更改的dirs,但尚未完成。另一个改进是显示任何追踪回溯前面或后面的目标。 HTH。