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.
You can use the git clean command to remove untracked files. The -fd command removes untracked directories and the git clean -fx command removes ignored and non-ignored files.
Run 'git clean -n' to see a dry run; Run 'git clean -f' to force untracked file deletion; Use 'git clean -f -d' to remove untracked directories; Use 'git clean -f -x' to remove untracked .
Description. The p4 clean command takes the following actions when finding inconsistencies between files in a user's workspace and corresponding depot files: Files present in the workspace, but missing from the depot are deleted from the workspace. Files present in the depot, but missing from your workspace.
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.
Try (for Unix) from your top-level:
# Find all files and filter for those that are unknown by Perforce find . -type f | p4 -x - fstat 2>&1 > /dev/null | sed 's/ -.*$//' > /tmp/list ### manually check /tmp/list for files you didn't mean to delete # Go ahead and remove the unwanted files. xargs rm < /tmp/list
Or, for a clean -f kind of approach just pipe directly to xargs rm instead of first staging the file list in /tmp/list.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With