简体   繁体   English

在 Git 中创建分支时恢复已删除的文件

[英]Recover deleted files while creating a branch in Git

I have a branch in a Git and in that branch I have made my local changes.我在 Git 中有一个分支,在该分支中我进行了本地更改。

But to push to master I have created a new branch all the files in my previous branch which is in my local got deleted.但是为了推送到master,我创建了一个新分支,我本地的前一个分支中的所有文件都被删除了。

Is there a way to recover those?有没有办法恢复这些?

Have spend lot of time installing recovery softwares and going through all the posts but don't find anything useful.花了很多时间安装恢复软件并浏览所有帖子,但没有发现任何有用的东西。 So thought to ask the community for help.It will be very helpful to get some suggestions.所以想到向社区寻求帮助。得到一些建议会很有帮助。

Thanks in advance提前致谢

in that branch I have made my local changes在那个分支中,我进行了本地更改

And did you commit those changes?您是否提交了这些更改? If so, no problem;如果是这样,没问题; Git has them. Git有他们。 That is what Git is for!这就是 Git 的用途! They are part of the branch you were on, before you made this new branch.在您创建这个新分支之前,它们是您所在分支的一部分。 So, to see them again, you can check out that branch again, or you can merge that branch into this one, or you can even check out the files by name into the current branch.因此,要再次查看它们,您可以再次检出该分支,或者可以将该分支合并到该分支中,或者您甚至可以按名称将文件检出到当前分支中。

But if you somehow checked out a branch without committing the local changes in the old branch, then there is nothing you can do;但是,如果您以某种方式签出一个分支而没有在旧分支中提交本地更改,那么您将无能为力; Git is not responsible for anything but commits.除了提交之外,Git 不负责任何事情。

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

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