在 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.
Run Code Online (Sandbox Code Playgroud)
在 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
Run Code Online (Sandbox Code Playgroud)
如果文件未打开,但您已在本地对其进行了更改,请使用
p4 sync -f UI/FormMain.cs
Run Code Online (Sandbox Code Playgroud)
告诉 Perforce 强制 (-f) 将您计算机上的 FormMain.cs 副本与服务器上的版本同步。