简体   繁体   English

从 GIT 或 SVN 恢复已删除的文件

[英]Recover the Deleted files from GIT OR SVN

I had a folder structure with multiple projects in Visual Studio.我在 Visual Studio 中有一个包含多个项目的文件夹结构。 I committed a few in my old Repo of SVN. And when I added a few more projects, we decided to move to Git.我在我的旧 Repo SVN 中提交了一些。当我添加了更多项目时,我们决定移动到 Git。

While creating a new repo in Git and checking in, by mistake, I ran a Git reset --hard and it deleted all the files from local.在 Git 中创建新存储库并签入时,我错误地运行了Git reset --hard ,它从本地删除了所有文件。

These files do not exist in either SVN or Git repo.这些文件不存在于 SVN 或 Git 存储库中。

I tried to restore using the git fsck --lost-found , git show , git merge , git reflog .我尝试使用git fsck --lost-foundgit showgit mergegit reflog进行恢复。 But none of that works.但这些都不起作用。 It always shows me the whole list of files in Deleted.它总是向我显示已删除文件的整个列表。

I ran the git show 4825b63f49cea10539a4c27a6287e195d3d087b2 > 4825b63f49cea10539a4c27a6287e195d3d087b2.txt after running git reflog .我在运行git reflog后运行了git show 4825b63f49cea10539a4c27a6287e195d3d087b2 > 4825b63f49cea10539a4c27a6287e195d3d087b2.txt And the text file does contain all the files with its code.文本文件确实包含所有文件及其代码。 But I am not able to restore it.但我无法恢复它。

Before I started with Git, the code was connected with SVN but may not be committed.在我开始使用 Git 之前,代码与 SVN 连接但可能无法提交。

Is there any way I can restore the code from Git or SVN?有什么方法可以恢复 Git 或 SVN 的密码吗?

If 4825b63f49cea10539a4c27a6287e195d3d087b2 is a commit, you can try at least如果4825b63f49cea10539a4c27a6287e195d3d087b2是提交,您至少可以尝试

cd /path/to/repo
git restore 4825b63f49cea10539a4c27a6287e195d3d087b2 -- .

See if the content of that commit is visible then.然后查看该提交的内容是否可见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM