這裏有一個快速「東經髒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。