如何从仓库中删除文件,但保留本地副本不变?

发布于 2024-08-16 19:39:29 字数 381 浏览 4 评论 0原文

我正在尝试学习 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

魔法少女 2024-08-23 19:39:30

有一种方法可以做到这一点,那就是在 Perforce 的背后。执行以下操作:

  1. 将要删除的文件重命名为新文件
  2. 在原始文件名上运行 p4 delete
  3. p4 提交 更改
  4. 将文件重命名回原始名称

There is a way to do this, by going behind Perforce's back. Do the following:

  1. Rename the file you want to delete to something new
  2. Run p4 delete on the original filename
  3. p4 submit the change
  4. Rename the file back to the original name
梦年海沫深 2024-08-23 19:39:30

我不相信有任何方法可以在 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.

英雄似剑 2024-08-23 19:39:30

其他一些命令带有一个参数,可以让您伪造该操作,但删除则不然。您始终可以创建一个新客户端,在该工作区中进行删除。

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.

唱一曲作罢 2024-08-23 19:39:30
  1. 在“工作空间”选项卡中,转到包含要从源中删除的文件的文件夹
  2. 右键单击该目录(或从文件菜单),然后选择在此处打开命令窗口
    • 注意 - 如果您在源目录中打开自己的命令提示符,您可能会遇到此错误:
      “客户端‘your-client’未知 - 使用‘client’命令创建它。”
  3. 输入命令 p4 delete -k
  4. 更改将添加到您的 P4V Helix 变更列表已准备好签入
  1. In the Workspace tab go to folder containing file(s) to remove from source
  2. Right-click on that directory (or from File menu) and choose Open command window here
    • Note - If you open your own command prompt in the source directory you may encounter this error:
      "Client 'your-client' unknown - use 'client' command to create it."
  3. Enter command p4 delete -k <file_to_delete>
  4. Change will be added to your P4V Helix changelist ready to check in
江挽川 2024-08-23 19:39:30

我认为命令 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文