search

Home  >  Q&A  >  body text

git checkout -- . 可以反悔吗

不慎在错误的目录执行了git checkout -- .,导致最近的更改都被恢复成commit时的状态。
是否有命令可以找回丢失的更改呢?

大家讲道理大家讲道理2834 days ago656

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-04-24 09:12:50

    The content added to the index can be retrieved (but only the file content, no file name information, requires manual identification), the parts that have not been added have been deleted, you can only resort to other methods (backup files, undelete recovery, etc.).

    reply
    0
  • 迷茫

    迷茫2017-04-24 09:12:50

    As far as I know, you can’t restore without stage changes.

    If stage(add) is passed, it may be possible to recover (provided that git gc cannot be run): Use git fsck --lost-found 找到 dangling blob,然后使用 git show <sha_id> to see if this file is one you have restored before.

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-24 09:12:50

    git reset --hard HEAD~1 You can recover

    reply
    0
  • Cancelreply