如何将文件从 perforce 下载到工作区以外的位置?

发布于 2024-10-05 04:44:43 字数 193 浏览 5 评论 0原文

我想从 Perforce 获取文件而不将它们放入工作区。

例如 我已经更改了 2 个文件。

file1.cs 
file2.cs

现在我想使用更新的 file1.cs 构建项目,因此我想获取除 file1.cs 之外的最新文件。

我想我会得到另一个项目的本地副本并构建它。

I want to get files from Perforce without putting them into a workspace.

E.g.
I have made changes in 2 files.

file1.cs 
file2.cs

Now I want to build the project using updated file1.cs, so I want to get latest files except for file1.cs.

I thought I will get another local copy of project and build it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(7

彼岸花似海 2024-10-12 04:44:43

我不确定您真正想要做什么,但是您可以通过使用“p4 print"。例子:

>p4 print -o fileName.cs //depot/path/to/fileName.cs

I'm not sure what you really want to do, but you can get the contents of a file from the depot without using a workspace definition by using "p4 print". Example:

>p4 print -o fileName.cs //depot/path/to/fileName.cs
无妨# 2024-10-12 04:44:43

据我所知,如果不使用工作区,则无法从 Perforce 仓库同步文件,因为这是它跟踪工作区中文件版本以及将它们放在本地计算机上的位置的方式(以及一些其他事情)。
我不确定我完全理解你的问题,但如果你需要做的是获取仓库中 file1.cs 的另一个副本,而不删除你对其所做的更改,你可以简单地将更改复制到另一个位置或搁置他们并重新同步文件。更完整且危险性较小的解决方案是创建另一个工作区,指向计算机上的不同物理位置但相同的仓库位置。
这解释了如何在需要时创建工作区:
http://www.perforce.com/perforce/doc.062 /manuals/boilerplates/quickstart.html
确保“根”路径与当前工作区的路径不同,您可以通过转到 P4V 中的工作区选项卡并查看来检查当前工作区根目录。
创建新工作区后,创建一个新连接并选择它,然后同步您需要的文件。

As far as I am aware you cannot sync files from a Perforce depot without using a workspace since this is the way it tracks what version of files you have in your workspace and also where to put them on your local machine (as well as a few other things).
I'm not sure I entirely understand your problem but if what you need to do is get another copy of the file1.cs you have in the depot without removing the changes you have to it you can simply copy the changes to another location or shelve them and re-sync the file. The more complete and less dangerous solution is to create another workspace pointing to a different physical location on your machine but the same depot location.
This explains how to create a workspace if you need it:
http://www.perforce.com/perforce/doc.062/manuals/boilerplates/quickstart.html
Make sure the 'Root' path is different to that of your current workspace, you can check what your current workspaces root is by going to the workspace tab in P4V and viewing it.
Once you have created the new workspace create a new connection and select it then sync the file(s) you need.

没有伤那来痛 2024-10-12 04:44:43

如果您在用户界面中,则可以使用“文件”->“导出到...”,这会将所选文件复制到您想要的任何文件夹。

输入图片此处描述

If you're in the UI you can use File->Export To... which will copy the selected file to any folder you want.

enter image description here

灼痛 2024-10-12 04:44:43

所以我想获取除 file1.cs 之外的最新文件

你不应该这样做;您应该更新所有文件并解决与 file1.cs 的任何冲突

考虑以下情况:其他人对 file56.cs 进行了更改,而该更改又依赖于对 file1.cs 所做的更改。如果您采用他们的更改列表但覆盖(或不采用)他们的 file1.cs,那么您的构建将会中断。

So I want to get latest files except file1.cs

You shouldn't do that; you should update all files and resolve any conflicts with file1.cs

Consider the situation where someone else has made changes to file56.cs that relies on changes also made to file1.cs. If you take their changelist but overwrite (or do not take) their file1.cs, then your build will break.

柠檬色的秋千 2024-10-12 04:44:43

我找到了一种使用 git 实现此操作的简单方法:

 $ git p4 clone //depot/your/folder

I found an easy way of doing this with git:

 $ git p4 clone //depot/your/folder
热情消退 2024-10-12 04:44:43

搁置 file1.cs,以便您可以安全地恢复本地更改:

p4 shelve file1.cs
p4 revert file1.cs

现在您可以使用您想要的任何版本的 file1.cs 进行构建(您可以同步回旧版本或其他版本)。

当您准备好返回找零时:

p4 unshelve -s CHANGE

Shelve file1.cs so you can safely revert your local change:

p4 shelve file1.cs
p4 revert file1.cs

Now you can do your build with whatever version of file1.cs you want (you can sync back to an older version or whatever).

When you're ready to return to your change:

p4 unshelve -s CHANGE
你好,陌生人 2024-10-12 04:44:43

我找到了解决方法,但没有找到解决方案。
我获取项目的另一个本地副本,然后构建项目并提交更改。

I found the workaround but not the solution.
I get another local copy of project then build the project and submit the change.

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