Search code examples
githubrepositoryundo

GitHub undo a discard


I was working on some files and accidentally discarded all the files from github. I know that as soon as you discard there is an undo button at the bottom. But I restarted my gitub and now I do not have the undo button anymore. Is there any way I can undo my discard and get back my files? I hope there is, pls let me know if you have any ideas.

Thanks!


Solution

  • The discard (that you can see in "Undo Button in GitHub for Windows") is available to reset files added to the index.

    https://f.cloud.github.com/assets/1396/278196/785c1940-90df-11e2-9c77-189a907c6580.gif

    That means you added files, and reset them before any commit.

    The GitHub for Windows/Mac won't help you there.

    You need to recover those files from the git repo (git fsck --unreachable --no-reflogs --no-cache HEAD).
    See "Recovering added file after doing git reset --hard HEAD^" for more.

    The OP Benz_java mentions "restoring lost commits", for looking in the reflog for lost commit.