How to remove untracked files from a Perforce working tree?

Simon Perreault picture Simon Perreault · Aug 31, 2009 · Viewed 19.3k times · Source

What's the equivalent of "git clean" with Perforce?

git-clean - Remove untracked files from the working tree

Cleans the working tree by recursively removing files that are not under version control, starting from the current directory.

-x Don’t use the standard ignore rules read from .gitignore (per directory) and $GIT_DIR/info/exclude, but do still use the ignore rules given with -e options. This allows removing all untracked files, including build products. This can be used (possibly in conjunction with git reset) to create a pristine working directory to test a clean build.

-X Remove only files ignored by Git. This may be useful to rebuild everything from scratch, but keep manually created files.

Answer

scott77777 picture scott77777 · May 8, 2013

Using P4V, you can right click on a folder and select "Reconcile Offline Work...". In the middle panel ("Local files not in depot"), all the files that Perforce can find in the folder tree that are not in the depot will be listed. You can select some or all of these and right click and select "Delete Local File"

This isn't a script, but it's much easier than most other solutions on Windows.