[英]how do I recover a missing file in azure devops
a code file is missing from my repository and in visual studio I get the error "the item does not exist in the project director it might have been moved renamed or deleted" How can I recover the fileA?我的存储库中缺少一个代码文件,在 visual studio 中我收到错误消息“该项目在项目主管中不存在,它可能已被移动重命名或删除”如何恢复 fileA?
If you deleted the fileA, the ways to restore a deleted file depends on how convinced you were at the time you really wanted the file to be deleted.如果您删除了文件 A,则恢复已删除文件的方法取决于您当时是否真的希望删除该文件。
1 deleted a file but didn't commit 1 删除了一个文件但没有提交
git checkout HEAD <filename>
This will work regardless of whether the deletion was staged or not.无论删除是否已上演,这都将起作用。 2 deleted a file and committed the deletion
2 删除文件并提交删除
$ git reset --hard HEAD~1
3 committed the deletion and then did more commits 3 提交了删除,然后做了更多的提交
(1) check the history for the deleted file and get the commit hash (1) 查看被删除文件的历史记录,得到commit hash
git log -- <filename>
For example:例如:
(2) You can either work with the last commit that still had the file, or the commit that deleted the file (2) 您可以使用仍然有文件的最后一次提交,也可以使用删除文件的提交
git checkout <commit hash> -- <filename>
git checkout <deletion commit hash>~1 -- <filename>
4 deleted a file,committed and pushed 4 删除一个文件,提交并推送
git revert --no-commit <commit>
If you rename the fileA to a new name, please rename it to original name.如果您将文件 A 重命名为新名称,请将其重命名为原始名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.