Recover from git reset --hard?

后端 未结 22 2556
盖世英雄少女心
盖世英雄少女心 2020-11-22 00:52

Is there any way to recover uncommitted changes to the working directory from a git reset --hard HEAD?

22条回答
  •  后悔当初
    2020-11-22 01:54

    (answer suitable for a subset of users)

    If you're on (any recent) macOS, and even if you're away from your Time Machine disk, the OS will have saved hourly backups, called local snapshots.

    Enter Time Machine and navigate to the file you lost. The OS will then ask you:

    The location to which you're restoring "file.ext" already contains an
    item with the same name. Do you want to replace it with the one you're
    restoring?
    

    You should be able to recover the file(s) you lost.

提交回复
热议问题