Question

I have a git repository that I'm trying to delete all files and folders out of but not the .git folder. I've tried various permutations of the -exclude parameter but can't seem to get it.

$repoPath = "c:\myrepo"
Remove-Item $repoPath -Recurse -Force -Exclude .git
Remove-Item $repoPath -Recurse -Force -Exclude *.git*
Remove-Item $repoPath -Recurse -Force -Exclude *.git

No matter what I try the .git folder gets deleted. Any suggestions?

Was it helpful?

Solution

Remove-Item $repoPath will remove the entire folder. Don't you mean do use Remove-Item $repoPath\*?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top