我是 Perforce 的新手,老实说,我讨厌它。我的 c:\workspaces\perforce 目录中有大约 20 个文件,我选择了所有文件并按下删除键。在我删除它们之前,它们都已签入。我一直在努力想办法让它们恢复原状(Perforce 太不直观了),但对于像我这样的 n00b 来说,没有什么比这更突出的了。
我怎样才能从 Perforce 将最新的修订版本返回到目录中?
8 回答
您需要进行强制同步。
在命令行上:
$> p4 sync -f
在 P4V 图形用户界面中:
- 右键单击目录进行更新
- 选择“获取修订版”
- 在对话框中,选中“强制操作”
- 点击“获取修订”
The perforce server keeps track of which files you pulled in last time. This is done so that, the next sync
only brings in the files which have changes since the last sync, instead of all the files once again.
To override this behavior, you need to use the -f
option.
The -f flag forces resynchronization even if the client already has the file, and overwriting any writable files. This flag doesn't affect open files.
If you're using the command line client, you can run this command from the directory where you want to sync up:
p4 sync -f ...
You might also want to check the list of opened
files, since sync -f
will not be bringing in changes corresponding to those files (even if you have deleted them).
This command should list all the opened files:
p4 opened ...
If you have any files listed in the above list, which you had deleted as well, you should revert them before running sync -f
.
p4 revert <FILE1> <FILE2>
p4 sync -f ...
If you're using p4v
, you could follow the steps mentioned by dwinkle:
1. Right click the folder in your workspace
2. Choose `Get Revision` in the context menu.
3. Choose `Get Latest revision`
4. Check `Force Operation (replace file even if you already have the revision specified)
5. Click on `Get Revision` button to fetch the files.
To look at the list of opened files using p4v
, you would have to look at your list of pending changelists. You should be looking in the default
changelist, if you have not put the files in any speficic changelist. Right click on files that you see there that you had deleted earlier, and choose Revert
.
如果您已签出文件,然后将其删除。在获得最新强制 (p4 sync -f) 之前,您需要恢复(p4 revert -a //...)文件夹。
如果您不关心旧客户端,一种解决方案是拉下一个新客户端:
p4 newclient
p4 sync
如果您希望客户端具有相同的名称,您可以像其他人提到的那样进行强制同步:
p4 sync -f
如果您希望客户端具有相同的名称,但您的目录不再被识别为 p4 工作区,则需要删除客户端然后重新创建它。
p4 -c <client_name> client -d <client_name>
p4 newclient
替代:
p4 reconcile
p4 revert //...
- 右键单击父目录。
- 在上下文菜单中单击“协调”。
- 创建一个新的更改列表。
- 右键单击更改列表。
- 还原更改。
就我而言,我尝试了一切,但无法恢复所有文件,因此我尝试删除它们,但无法恢复所有文件。我重新启动了我的电脑,并尝试了许多在网上找到的解决方案。最后,我的问题通过以下一项或全部解决:升级到最新的 P4V 应用程序,以提升的权限运行应用程序,并在强制获取最新后去吃午饭。
如果你浪费了半天时间。您可能想尝试上述方法。
我已经删除了我目录中的所有文件。我怎样才能让他们回来?
我刚刚偶然发现的一个问题是,如果您删除了该目录,您就不能只用p4 sync -f
它来取回它。我想要一个完整的干净版本的目录,所以我做了一个:
rm -rf directory1
但是,当我p4 sync -f directory1
对其进行操作时,它会吐出:
directory1 - no such file(s).
我发现有效的是首先恢复目录中的文件:
p4 sync -f directory1/some-file
您必须知道可以使用的缺失目录中的文件之一的名称:
p4 files //depot/some/path/directory1/\*
获得其中一个文件名后,请执行以下操作:
p4 sync -f directory1/some-file
这应该创建directory1
目录。然后您可以在创建的目录中进行完全同步:
cd directory1
p4 sync -f ...
希望这对其他人有帮助。