Perforce 中的已删除(未提交)目录:无法还原、强制同步、协调或执行任何其他操作
Deleted (not submitted) directory in Perforce: cannot revert, force-sync, reconcile or do anything else
我在第 3 方 Perforce 客户端中删除了一个目录。它应该使用 p4 delete
,但我不能确定。未提交。
现在:
- 我在 p4v 中没有看到删除的目录。
p4 revert
失败:
p4 revert //depot/path/deleted-directory/...
//depot/path/deleted-directory/... - file(s) not opened on this client.
我无法强制同步 deleted-directory
来恢复删除:
p4 sync -f //depot/path/deleted-directory
//depot/path/deleted-directory no such file(s).
p4 sync -f //depot/path/deleted-directory/...
//depot/path/deleted-directory/file1.txt#2 - deleted as /Users/me/depot/path/deleted-directory/file1.txt
无法和解:
p4 reconcile //depot/path/deleted-directory/...
//depot/path/deleted-directory/... - no file(s) to reconcile.
p4 opened
没看到:
p4 opened
File(s) not opened on this client.
如何将这个已删除的目录放入更改列表或至少恢复它?
我尝试了“I've deleted all the files in my directory. How can I get them back?”的所有建议,除了检查一个新的工作区,我最终会这样做。
简答:
p4 undo //depot/path/deleted-directory/...#head
p4 submit
这将通过创建从先前版本复制的新修订来撤消该目录中的主要修订(即删除)。
解释为什么您尝试过的所有方法都不起作用的更长答案:
p4 opened
和 p4 revert
都对当前 打开 的文件进行操作。如果您尚未提交,那么 revert
会将文件放回原处,但由于此删除已提交,因此没有打开的文件可还原。
当您强制同步时,您只是强制重新同步到已删除的主要修订版(就像您工作区中的文件一样),所以无论您多么努力地强制同步,您都会进行得到的是很多东西。如果你这样做了:
p4 sync "//depot/path/deleted-directory/...#<head"
为了同步到 #head
之前的修订版,这样就可以了。请注意,不需要 -f
标志。一旦文件同步到正确的修订版,您还可以通过以下同步命令撤消删除:
p4 add //depot/path/deleted-directory/...
p4 submit
类似地,reconcile
没有做任何事情,因为文件在 head 修订版中被删除并在您的工作区中被删除,所以没有什么可以协调的。如果你想对它变得非常奇怪,你可以通过 sync
和 flush
的组合来通过 reconcile
撤消删除,以模拟重新添加文件的新副本的情况:
p4 sync "//depot/path/deleted-directory/...#<head"
p4 flush //depot/path/deleted-directory/...
p4 reconcile //depot/path/deleted-directory/...
除了不必要的复杂之外,这个基于 reconcile
的解决方案将丢失重新添加的文件来自哪个版本的信息(感谢 p4 flush
),所以我不会推荐它。使用 undo
如果您使用的是不支持的旧服务器版本,请执行正常的 sync
/add
操作。
我在第 3 方 Perforce 客户端中删除了一个目录。它应该使用 p4 delete
,但我不能确定。未提交。
现在:
- 我在 p4v 中没有看到删除的目录。
p4 revert
失败:p4 revert //depot/path/deleted-directory/... //depot/path/deleted-directory/... - file(s) not opened on this client.
我无法强制同步
deleted-directory
来恢复删除:p4 sync -f //depot/path/deleted-directory //depot/path/deleted-directory no such file(s). p4 sync -f //depot/path/deleted-directory/... //depot/path/deleted-directory/file1.txt#2 - deleted as /Users/me/depot/path/deleted-directory/file1.txt
无法和解:
p4 reconcile //depot/path/deleted-directory/... //depot/path/deleted-directory/... - no file(s) to reconcile.
p4 opened
没看到:p4 opened File(s) not opened on this client.
如何将这个已删除的目录放入更改列表或至少恢复它?
我尝试了“I've deleted all the files in my directory. How can I get them back?”的所有建议,除了检查一个新的工作区,我最终会这样做。
简答:
p4 undo //depot/path/deleted-directory/...#head
p4 submit
这将通过创建从先前版本复制的新修订来撤消该目录中的主要修订(即删除)。
解释为什么您尝试过的所有方法都不起作用的更长答案:
p4 opened
和 p4 revert
都对当前 打开 的文件进行操作。如果您尚未提交,那么 revert
会将文件放回原处,但由于此删除已提交,因此没有打开的文件可还原。
当您强制同步时,您只是强制重新同步到已删除的主要修订版(就像您工作区中的文件一样),所以无论您多么努力地强制同步,您都会进行得到的是很多东西。如果你这样做了:
p4 sync "//depot/path/deleted-directory/...#<head"
为了同步到 #head
之前的修订版,这样就可以了。请注意,不需要 -f
标志。一旦文件同步到正确的修订版,您还可以通过以下同步命令撤消删除:
p4 add //depot/path/deleted-directory/...
p4 submit
类似地,reconcile
没有做任何事情,因为文件在 head 修订版中被删除并在您的工作区中被删除,所以没有什么可以协调的。如果你想对它变得非常奇怪,你可以通过 sync
和 flush
的组合来通过 reconcile
撤消删除,以模拟重新添加文件的新副本的情况:
p4 sync "//depot/path/deleted-directory/...#<head"
p4 flush //depot/path/deleted-directory/...
p4 reconcile //depot/path/deleted-directory/...
除了不必要的复杂之外,这个基于 reconcile
的解决方案将丢失重新添加的文件来自哪个版本的信息(感谢 p4 flush
),所以我不会推荐它。使用 undo
如果您使用的是不支持的旧服务器版本,请执行正常的 sync
/add
操作。