Petter Petter - 4 months ago 27
Git Question

Powershell Command to Run "git gc" in all sub-directories that are git repos

I don’t know any PowerShell, but I do know how to search, copy and paste. I think the following command will run "git gc" for all sub-directories that are git repos.

dir -recurse -include .git | %{ git -C "$_.FullName\.." gc }

Any issues?

I am using the "git -C" functionality to set the directory to run in. How can I instead execute a command in a specific directory?

% { Set-Location $_.FullName; git gc }


% { Start-Process git -WorkingDirectory $_.FullName -ArgumentList gc}