如何从仓库中删除文件,但保留本地副本不变?
我正在尝试学习 Perforce 并想从仓库中删除一个文件(可以使用 p4 delete、p4 Submit 轻松完成),但这也会从客户端计算机目录结构中删除它。我想保持目录中的本地文件完好无损。
我认为做到这一点的唯一方法是在删除之前将其移出 Perforce 控制下的层次结构。我能够通过同步早期版本来恢复我的文件。
也许我的客户工作区设置错误?或者我误解了源代码控制的基本概念?客户端工作区是 /home/user ,我这样做了,这样我就可以在我的主目录下添加任何文件,而不会收到有关文件不在客户端根目录下的错误。
仅供参考 - 运行 P4D/LINUX26X86/2009.1/222893 的 Linux 客户端和服务器 (2009/11/12)
任何建议表示赞赏。 谢谢。
I'm trying to learn Perforce and want to delete a file from the depot(easy to do with p4 delete, p4 submit), but that deletes it from the client machine dir structure as well. I want to keep my local file in my directory intact.
The only way I can see to do this would be to move it out of the hierarchy that is under Perforce control before deleting. I was able to get my file back by syncing an earlier version.
Maybe I set up my client workspace wrong? Or am I misunderstanding a fundamental concept of source control? The client workspace is /home/user and I did it this way so I could add any file under my home directory without getting an error about the file not being under client's root.
FYI - Linux client and server running P4D/LINUX26X86/2009.1/222893 (2009/11/12)
Any advice appreciated.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
有一种方法可以做到这一点,那就是在 Perforce 的背后。执行以下操作:
p4 delete
p4 提交
更改There is a way to do this, by going behind Perforce's back. Do the following:
p4 delete
on the original filenamep4 submit
the change我不相信有任何方法可以在 Perforce 下保留您要删除的文件。这样做是有充分理由的,就好像文件在仓库中被删除一样,没有理由(从源代码控制的角度来看)在客户端工作区中保留副本。
我怀疑问题出在您使用 Perforce 的方式上。
从您所写的内容来看,您似乎正在使用 Perforce 来备份/跟踪主目录结构中的文件。因此,您使用 Perforce 的方式是“主目录”位于您的主目录中,“副本”位于仓库中。
据我了解,这不是源代码控制系统的预期用途。
所有文件的主副本实际上是仓库中的内容。从软件仓库中,创建多个客户端(视图)用于进行更改、测试等目的。客户端是暂时的,可以根据需要创建和删除。
为了做您想做的事情,您可能需要重新考虑如何使用 Perforce。
I don't believe there is any way to keep a file you are deleting under Perforce. There is good reason for this, as if the file is deleted in the depot there is no reason (from a source code control perspective) to keep a copy in the client workspace.
I suspect the issue is the way you are using Perforce.
From what you have written it seems that you are using Perforce to backup/track files in your home directory structure. So the way you are using Perforce the "master" is in your home directory and the "copies" are in the depot.
This is not the intended use of a source control system as I understand it.
The master copy of all files are actually what is in the depot. From the depot, multiple clients (views) are made for purposes such as making changes, testing, and so on. The clients are transitory and can be created and deleted as required.
To do what you want to do you may need to rethink how you are using Perforce.
其他一些命令带有一个参数,可以让您伪造该操作,但删除则不然。您始终可以创建一个新客户端,在该工作区中进行删除。
some of the other commands take a parameter that lets you fake the action, but delete doesn't. You could always make a new client, do the delete in that workspace.
“客户端‘your-client’未知 - 使用‘client’命令创建它。”
p4 delete -k
"Client 'your-client' unknown - use 'client' command to create it."
p4 delete -k <file_to_delete>
我认为命令
p4 obliterate
就是您正在寻找的。https://www.perforce.com/perforce/doc.091/manuals/cmdref/obliterate.html#:~:text=Once%20p4%20obliterate%20completes %2C%20it,因为%20是%20在%20Perforce%20控制下。
回答一下之前的热门答案。您可能不希望在您的仓库中缓存/编译/用户设置,因为客户端可以自己创建这些设置。删除将导致所有客户端都需要重新编译,而删除可能会完成手头的任务。您可能希望事先将文件标记为可写,这样它们就不会在客户端上保持只读状态,具体取决于您的
p4 类型映射
The command
p4 obliterate
is what you are looking for I think.https://www.perforce.com/perforce/doc.091/manuals/cmdref/obliterate.html#:~:text=Once%20p4%20obliterate%20completes%2C%20it,as%20being%20under%20Perforce%20control.
To answer the previous popular answer. You may not want cached/compiled/user settings in your depot as clients could create these for themselves. A delete will cause all clients to need to recompile while an obliterate would likely accomplish the task at hand. You may want to mark the files as writeable prior so that way they aren't left as read-only on clients depending on your
p4 typemap