Git pull deleted uncommitted changes

前端 未结 5 1877
有刺的猬
有刺的猬 2020-12-03 18:29

I just made a new repository on github. Starting with a folder full of files, the steps I did were:

git init
git add -A
git remote add origin ...

#Now pull          


        
5条回答
  •  死守一世寂寞
    2020-12-03 19:27

    I agree with the accepted answer, however in my case there were too many results for git fsck. This solution is what helped me locate the lost files:

    Search for a string in the missing file(s):

    grep -rin  .git/
    

    For example:

    grep -rin MyClassName .git/
    

    Search results:

    .git//lost-found/other/3cfaa36226f52a5c1b38c2d2da3912656c998826:5:class MyClassName extends ParentClass
    .git//lost-found/other/e7b8923de4afb230ad523b5b515f50cb9c624248:5:class MyClassName extends ParentClass
    

    Where search results are:

    .git/::
    

    Then to restore the file:

    git cat-file -p 3cfaa36226f52a5c1b38c2d2da3912656c998826 > ..//MyClassName.php
    

提交回复
热议问题