[英]How to recover files in git repository
I had a project connected to a local git repository. 我有一个项目连接到本地git存储库。 I decided to reinit that after some mess with branches and commits.
在决定对分支和提交进行一些混乱之后,我决定重新进行初始化。 Firstly, I deleted old repository with "rm -r .git", and than created new one with "git init".
首先,我使用“ rm -r .git”删除了旧存储库,然后使用“ git init”创建了新存储库。 After that, I found out my work directory looking the same way as if my project was only created - the results of all my work are gone.
在那之后,我发现我的工作目录看起来就像只创建我的项目一样-我所有工作的结果都消失了。
Trying many recipes from the internet didn't give results. 从互联网上尝试许多食谱都没有得到结果。 Please, give me a cue, is there any chance to recover my project's files or not.
请给我一个提示,是否有机会恢复我项目的文件。
In the case your "local repository" means you did git clone /path/to/your/local/repo
, yes you can restore it by cloning again with git ckibe /path/to/your/local/repo
, or git remote add origin /path/to/your/local/repo && git fetch && git pull origin/master
). 如果您的“本地存储库”意味着您做了
git clone /path/to/your/local/repo
,是的,您可以通过使用git ckibe /path/to/your/local/repo
或git remote add origin /path/to/your/local/repo && git fetch && git pull origin/master
再次克隆来恢复它git remote add origin /path/to/your/local/repo && git fetch && git pull origin/master
)。
Same thing if you cloned from a remote repository. 如果是从远程存储库克隆的话,也是一样。
Otherwise, there is no way to recover your files with git, except if you removed by a graphical interface (which move to a trash folder instead of making a real deletion) or if you have a back up. 否则,除非通过图形界面(将其移至垃圾箱而不是真正删除)移动到图形界面,否则将无法使用git恢复文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.