7

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!

Biggy_java
  • 455
  • 1
  • 4
  • 16

1 Answers1

6

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • This post was very helpful too: http://gitready.com/advanced/2009/01/17/restoring-lost-commits.html – Biggy_java Mar 12 '14 at 18:39
  • 1
    @Benz_java indeed, for restoring commits. I have included your link in the answer for more visibility. – VonC Mar 12 '14 at 18:43
  • Thanks guys, this helped me to recover all of my week's work! – Biggy_java Mar 12 '14 at 18:59
  • @VonC Thank you. Also, I have seen you before from a different answer a year or two ago. Good to see another helpful answer from you again :) – Marvin Apr 21 '20 at 21:39
  • @Marvin No problem. I am here everyday (https://meta.stackexchange.com/q/122976/6309). – VonC Apr 22 '20 at 05:21