如何在Perforce中还原文件?

如何在Perforce中还原文件?,perforce,Perforce,在Perforce中,如何恢复对文件所做的更改 $ p4 status UI\FormMain.cs - reconcile to edit //UI/FormMain.cs#73 $ p4 revert UI/FormMain.cs UI/FormMain.cs - file(s) not opened on this client. 在Git中,我使用命令Git checkout来实现这一点 $ git status # On branch master # Changes not s

在Perforce中,如何恢复对文件所做的更改

$ p4 status
UI\FormMain.cs - reconcile to edit //UI/FormMain.cs#73

$ p4 revert UI/FormMain.cs
UI/FormMain.cs - file(s) not opened on this client.

在Git中,我使用命令
Git checkout
来实现这一点

$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   Form.cs
#
no changes added to commit (use "git add" and/or "git commit -a")

$ git checkout Form.cs

$ git status
# On branch master
nothing to commit, working directory clean
$git状态
#论分行行长
#未为提交而暂存的更改:
#(使用“git add…”更新将提交的内容)
#(使用“git签出--…”放弃工作目录中的更改)
#
#修改:Form.cs
#
未向提交添加任何更改(使用“git add”和/或“git commit-a”)
$git checkout Form.cs
$git状态
#论分行行长
没有要提交的内容,正在清理目录

您应该调用
p4 revert//UI/FormMain.cs
而不是
p4 revert UI/FormMain.cs
,因为这是仓库符号中的绝对路径。
不带前导字符的文件将标记相对于客户端工作区中当前位置的文件。

如果该文件尚未打开,但您已在本地对其进行了更改,请使用

p4 sync -f UI/FormMain.cs

告诉Perforce强制(-f)将您计算机上的FormMain.cs副本与服务器上的版本同步。

这不起作用,它会给我相同的“未在此客户端上打开的文件”。错误。“p4已打开”是什么意思告诉你?
p4 revert
仅适用于使用
p4 edit
或通过P4V应用程序中的签出操作打开进行编辑的文件。通常的性能工作流是在触摸文件之前,首先通过
p4 edit
显式打开文件进行编辑(否则,当您尝试
p4 revert
)时,服务器将不知道也不会做任何事情。如果您遵循这种做法,事情会进展得更顺利。