Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 488
Biggy_java Avatar asked Mar 11 '14 16:03

Biggy_java


People also ask

Can you undo git discard?

The "restore" command helps to unstage or even discard uncommitted local changes. On the one hand, the command can be used to undo the effects of git add and unstage changes you have previously added to the Staging Area.

How do you get back discarded changes?

Press Ctrl+z for Undo & CTRL+S for saving the changes.

How do you get discarded changes back in VS code?

Ctrl + Z or restore from trash. I have lost work to this multiple times, and to remedy this, I commit all the changes, then reset the branch to the previous commit. Then you can run git discard to discard the changes, but keep a reference in the reflog.

How do I undo a restore on github?

If you know where the last changes were made and you didn't close the IDE, just go to that particular file and try undo (ctrl+z).


1 Answers

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.

like image 145
VonC Avatar answered Oct 06 '22 19:10

VonC