这两个命令之间有什么区别,如果有的话:
# revert my file to the revision last synced from the depot
p4 revert test.c
# force synchronization to refresh file and discard pending changes
p4 sync -f test.c
Run Code Online (Sandbox Code Playgroud)
谢谢
在您的方案中,命令类似,但是:
revert只会还原当前标记为打开的文件; sync -f只会覆盖未打开的文件.revert需要文件模式作为参数,sync -f不需要.sync -f 即使您当前的副本未经修改,服务器也会向您发送该文件的新副本,因此有点浪费计算机时间和网络资源.还有其他差异,但它们对您的方案似乎不太重要.
在我看来,将工作空间返回到未修改状态的最好方法实际上是使用p4 clean,它在2014.1版本中添加到服务器中.这是关于该clean命令的一篇很好的文章:https://www.perforce.com/blog/140501/p4-clean-make-workspace-shine
对于其他替代方案,请参阅此相关问题:Perforce将目录快速同步到干净状态