Petter Petter - 1 year ago 83
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?

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


% { Start-Process git -WorkingDirectory $_.FullName -ArgumentList gc}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download