Here is my requirement:
- Iterate through all the subfolders of the given directory.
- In each subfolder, delete all local branches except master branch.
For item#2, the following statement works when manually executed in a subfolder.
git branch | grep -v " master" | xargs git branch -D
I want to create a batch file that will execute the above statement in each subfolder.
I tried the following but could not make it work. Please help me identify what's wrong with the statement.
FOR /D %%G in ("C:\parent\*") Do (echo Updating %%G ...) && (cd %%G) && git branch | grep -v " master" | xargs git branch -D