Skip to content

Instantly share code, notes, and snippets.

@JoaoMotondon
JoaoMotondon / git_clean_fxd_command.bat
Created December 16, 2017 18:05
Windows batch script that searches for git repositories in a given directory and executes "git clean -fxd" command in all of them (except those which have untracked files)
@echo off
REM We need to delay expansion, otherwise variables inside 'for' block will get replaced when the batch processor reads them in the 'for' loop, before it is executed.
REM See this link for details: https://stackoverflow.com/questions/5615206/windows-batch-files-setting-variable-in-for-loop
setlocal enabledelayedexpansion
REM Iterate over all git repositories
for /f %%l in ('find . -name ".git"') do (
echo Checking dir:%%~dpnl