Home  >  Q&A  >  body text

git - 如何恢复Initial commit之前的源文件

在github新建了一个空的库,然后到本地文件夹下,git init了一下,将remote和本地的关联起来了,然后git pull了一下,本地的项目源码全没了,如何恢复,求大神搭救,万分感激!!!

PHPzPHPz2731 days ago717

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-04-28 09:06:35

    • git reflog: View commit history
    • git reset --hard id: id is the corresponding history found above, give it a try?

    reply
    0
  • PHP中文网

    PHP中文网2017-04-28 09:06:35

    Your operation will not cause file loss, please review your operation steps

    When git pull has untracked files locally, if there are no conflicts, these files will be ignored and will not cause file loss.
    If there is a conflict, the pull will fail and will not cause file loss

    reply
    0
  • PHP中文网

    PHP中文网2017-04-28 09:06:35

    I asked on stackoverflow and used git fsck --lost-found,然后文件会恢复在.git/lost-found/otherinside, but the directory structure and file name cannot be restored

    reply
    0
  • Cancelreply