实际上,如何从工作区中的目录中删除文件,而这些文件不属于工作区?
如果我要删除的文件不属于工作区,那么如何从工作区的目录中删除文件?
我的文件系统上有一个目录,其中包含从 perforce 获取的文件,但在某些进程运行后,它会在这些目录中创建一些新文件。
是否有 perforce 命令可以删除这些生成的不属于我的工作空间的文件?
In perforce how can I delete files from a directory in my workspace where the files I want deleted are not part of the workspace?
I have a directory on my file system with files it gets from perforce but after some processes run, it creates some new files in those directories.
Is there a perforce command to remove these generated files that are not part of my workspace?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
Perforce 2013.2 有一个
p4 status
命令,它是p4 reconcile -n
的别名,我不知道它在早期版本中是否可用。
Perforce 2013.2 has a
p4 status
command, which is an alias forp4 reconcile -n
I don't know if it was available in earlier versions.
这是我对
p4 nothave
的快速实现。这将生成一个文件列表,然后可以将其通过管道传输到 xargs rm 以便删除。不过,在删除之前请小心检查列表。你很可能会在那里发现你意想不到的东西。
This is my quick implementation of
p4 nothave
.This will produce a list of files, which can then be piped into
xargs rm
in order to be deleted. Be careful to inspect the list before deleting though. You may well find things you didn't expect in there.您还可以使用 p4v 和 p4 中的“协调离线工作”选项来完成此任务,而无需任何脚本。在 p4v 中,右键单击 Depot 视图中的任意目录,然后选择“协调离线工作”。
中间窗格将显示“本地文件不在仓库中”。您可以选择其中任何一个或全部,右键单击并选择“删除本地文件”。
简单的!
You can also use the "Reconcile Offline Work" option in p4v and p4 to accomplish this without any scripting. In p4v, right click any directory in Depot view and select "Reconcile Offline Work".
The middle pane will have "Local files not in depot". You can select any or all of these, right click and choose "Delete Local file".
Easy!
如果使用 Linux/Unix,在 Bourne shell 系列中,您可以键入
类似地,对于符号链接,键入
上面是字母“el”,而不是“one”。
我不知道 Windows 中是否有等效的。
If using Linux/Unix, in the Bourne shell family, you can type
Similarly, for symbolic links, type
Above is letter 'el', not 'one'.
Whether there is an equivalent in Windows I do not know.
您无法从 perforce 中修改/删除不属于您的工作空间的文件。您必须为此编写外部脚本。
You cannot modify/delete files that are not part of your workspace from within perforce. You will have to write external scripts for that.
这在 powershell 中有点尴尬,因为 p4 将“找不到文件”消息发送到错误流而不是 std 输出。
第二行应该产生诸如
“FILENAME.EXT - no such file(s)”之类的错误。
如果错误流中除了这些异常之外还有其他任何异常,那么它可能会有点不稳定,所以要小心。This is a little awkward in powershell, because p4 sends the can't-find-file message to the error stream rather than std out.
The second line should produces errors such as
"FILENAME.EXT - no such file(s)."
It can be a bit flaky if you have anything other than these exceptions in the error stream, so beware.您可以使用 p4 nothave 来确定不受 perforce 管理的文件。根据
p4 nothave
的输出,您也许可以执行p4 nothave | xargs rm
,但请务必在运行之前检查p4 nothave
的结果(这样您就不会意外删除重要的内容)。You can use
p4 nothave
to determine the files that are not managed by perforce. Depending on the output ofp4 nothave
you might be able to dop4 nothave | xargs rm
, but be sure to check the result ofp4 nothave
before running that (so that you don't delete something important by accident).