$local:workTree = git worktree list --porcelain | Select-String worktree | ForEach-Object { $_ -split 'worktree ' } | Where-Object { $_ } Push-Location $workTree $null = git reset HEAD $null = git rm --cached -r . $null = git add . git status Pop-Location