“Git Clean -fdx” recovery… possible?

浪子不回头ぞ 提交于 2019-12-11 17:31:32

问题


I probably did a huge mistake.

relevant system info:

  • Windows XP SP2
  • i686 Cygwin 1.7.6 git
  • 1.7.1

I was trying to create an empty branch on a newly created git repository, here are the commands I just issued:

git init
git symbolic-ref HEAD refs/heads/klist 
rm .git/index   <---- this command failed obviously, there was no index. 
git clean -fdx  <---- this is my nightmare

problem is I was not aware the clean command really deletes the files that are in the current folder, and as this was a newly initialized git repository there is no old version to revert to.

Some of the files I have them uploaded on my home page but some are not. Any ideas on how to recover the files will be appreciated. I dont mind using any kind of recovery software, and I am aware that losing files on linux/cygwin is a pain if not impossible to recover, but hey lets give it a shot.


回答1:


git clean removes untracked content, which by definition is something the repository knows nothing about. That's why it by default does nothing, requiring the -f option to do anything - it's essentially likecalling rm on everything untracked. You're pretty much stuck in desperate recovery territory at that point - as if you'd done rm -rf * yourself by accident. The files may still be on the disk, if you're lucky. Google around for "recover deleted files", or perhaps ask on superuser.



来源:https://stackoverflow.com/questions/3681474/git-clean-fdx-recovery-possible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!