0

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?

Micah
  • 111,873
  • 86
  • 233
  • 325
  • Won't `Remove-Item $repoPath` remove the entire folder? Don't you mean do use `Remove-Item $repoPath\*`? – Jay Sullivan Jun 20 '12 at 21:25
  • Yup, that was it. I was removing the top level folder instead of everything underneath of it. Thanks! – Micah Jun 20 '12 at 21:34

1 Answers1

3

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

Jay Sullivan
  • 17,332
  • 11
  • 62
  • 86