Skip to content

Instantly share code, notes, and snippets.

@jen20
Created November 23, 2013 19:12
Show Gist options
  • Select an option

  • Save jen20/7618685 to your computer and use it in GitHub Desktop.

Select an option

Save jen20/7618685 to your computer and use it in GitHub Desktop.
Powershell function to remove unversioned items from a Subversion working copy
Function Clean-SvnWorkingCopy {
Param(
[Parameter(Mandatory=$true, Position=0, HelpMessage="Path to the repository to clean")]
[string]$repositoryPath
)
Process {
Push-Location $repositoryPath
[xml]$svnChangelist = Exec { svn status --xml }
$entries = $svnChangelist.GetElementsByTagName("entry")
foreach ($change in $entries) {
if ($change.GetElementsByTagName("wc-status")[0].GetAttribute("item") -eq "unversioned") {
$toRemove = $change.GetAttribute("path")
Remove-Item -Force $toRemove
}
}
Pop-Location
}
}
@jen20

jen20 commented Nov 23, 2013

Copy link
Copy Markdown
Author

Probably wants updated to revert other files that are versioned

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment