none
Visual Studio Code just deleted all my files

    Question

  • I accidentally initialized a repository standing in my coding folder. It created a whole lot of pending changes since this was files not under source control or under TFVC source Control. To undo this I chose "Clean all" which I expected to behave like undo. But no, it seems to have made a permanent delete on ALL my files. I am novice to Git, so maybe this is how things work in the git world. This is a total disaster! They were not in the trashcan, so I guess all my work not versioncontrolled is lost. Will for sure never ever again use VS Code!!!
    Friday, April 15, 2016 9:13 PM

Answers

All replies

  • Hi mattias.sundstrom,

    Like Wosi's suggestion here:

    http://stackoverflow.com/questions/33235338/vs-code-delete-my-unity-project-os-xgit-clean-all

    It seems that it is by design, it would remove all files if you click "Clean all"(you will get some warning for you before you clean up it), we can't get it back using the Visual Studio Code. Maybe you could use OSX to help you restore the files or others.

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 18, 2016 8:35 AM
    Moderator
  • I Made the same mistake and lost all the files :( . So ridiculous. 
    Tuesday, January 10, 2017 6:59 AM
  • I did it as well but it was in the new repo I made.
    Wednesday, February 1, 2017 5:51 PM
  • Same as what I did before, all my files gone. Luckily to have a previous version backup code, but still lost a lot of my work :(.
    And also, I had been scared and I won't use this risky VS Code again anymore. Too bad.


    Wednesday, April 12, 2017 12:30 AM
  • This is damn disaster! That piece of crap didnt remeber any files I opened. So I open some folder to fix that ugly bug (which exists for more then year now: http://stackoverflow.com/questions/36328104/visual-studio-code-never-reopens-previous-file-or-folder ). Then I did almost the same actions as topic starter. I clicked "Undo all changes" after accidentally clicked on CVS and that stupid stuff grabs all files in my working archive... and BOOM! All gone. All hard work for years just PFF... GONE!

    I HATE EVERYONE WHO INVOLVED IN "VS CODE" REALIZATION, WHICH LED ME TO LOSING ALL MY ARCHIVE OF CODE.

    Who the hell in this world decided that it will be nice to automatically create some git repository just when user observing interface?


    Friday, May 12, 2017 6:00 PM
  • I did the same thing -.-

    Because I don't want it to create over 5000 branches

    Well, Onedrive is still recreating all files

    What a stupid, stupid thing to let happen without any further warning 

    Friday, May 19, 2017 8:01 AM
  • I did the same thing -.-

    Because I don't want it to create over 5000 branches

    Well, Onedrive is still recreating all files

    What a stupid, stupid thing to let happen without any further warning 

    Friday, May 19, 2017 8:02 AM
  • Same issue here, no idea what triggered this file delete.

    It does not appear in the recycle bin, 2 hours of sketching a script lost.

    I won't reuse vscode neither, too risky...

    Wednesday, May 31, 2017 1:31 PM
  • I too did the same mistake (but tried the "Discard All Changes" options instead) and there is no warning.. everything vanished not in Trashcan too :( Fed up...!!
    Monday, July 17, 2017 12:28 PM
  • After looking at various options and a frustrating 6 hours effort in fixing this issue, it seems like i found a quick solution to this frikkin problem.

    I want to go over my story first though

    I installed vs code, as soon as i opened the settings file, the GIT repository automatically initialized itself at the root of c:/User/WhateverUserName on my machine. This directory basically has all the work, emails, other software installation data, mail archives, and basically everything i ever did at this company in the last two years, basically all data under my USER Account in C: /USERS. I am very new to GIT and very well versed with TFS. I could see the GIT repository scroll bar going on and on for a while and i was waiting to see what the heck was it doing. After a few minutes, it threw an error something in the lines of 'There are many changes in folder and the CHANGES section would only show what is can'. Whatever option OK/Cancel that i clicked, it showed the number of changes to be more than 5000 (am assuming that is the limit that VS code GIT repo could show). My solution was actually stuck in showing all those files to me and vs code would hang. At this point i was not sure what I had done to see these 5000 changes. I immediately saw the discard all changes option and clicked on it. A popup then appeared asking for a confirmation for 'all these changes will be deleted'. you wish to proceed, and I clicked yes. Now i know many of you smart people might be thinking, why did i click OK when the message clearly said, 'All these changes will be deleted or This will delete all changes' kinda message. I come from TFS background, and a change is something you do, like add a new file to an existing solution in tfs, update an existing file or edit/delete it. How on earth would anyone think that a change is something that you did not even do, but GIT/VS code somehow initialized itself on the root of my User folder on C drive and that all the files that existed before even VS code was even installed is being taken as a change by GIT/VS Code? Whoever still thinks this is a change and I should know better (GFUS) because it is not. SO i was watching GIT do something in the background as soon as i clicked OK, I was a little skeptical it it was really deleting all these files from my computer or from whatever the default repo it created and assumed it was a change. I went to the first folder available under my USERS/myUserID and could see that the files are deleted, i was in shock and tried to find options to stop this darn thing. Luckily i was able to stop the delete in time before it removed all my files. 

    Frustrated and searching for root cause and solution at this point: I must have found another 40 people's posts in various blogs who went through the same pain. These folks who created VS Code/GIT integration UI did not have the ability to provide an option to select default GIT REPO at first initialization/installation step but had the ability to re write the definition for the word CHANGE in their GIT dictionary. I for one reason do not understand, why would you provide an option from GIT UI to delete all files permanently from the system? If this is how GIT works and experts in GIT have somehow gotten adjusted to it. Here is my 2 cents for them, 'Why would you make this product not so NEW user friendly?' And make it fatal for some of us like me where i would have risked losing all my data under my c:/Users/UserName. 

    Solution: I tried a couple of ways but the default GIT repository would only initialize at the  c:/Users/UserName. I now had no option but to find out where were these setting applied. After a few hours of research, i found this folder, titled, '.git' under my c:/Users/UserName folder and it was hidden so i had to enable 'view all files including hidden' option in the explorer. I moved this file to a separate folder on C drive where it was on its own. As soon as i did this and restarted my VS code, the CHANGES tab stopped showing all 10,000 files under my c:/Users/UserName as CHANGES. 

    These are in no way my views on GIT as a whole. I am pretty sure those people are doing an amazing job, but when you have an option to prevent such a huge mishap for a lot of people, why wouldn't you?

    Thursday, September 21, 2017 1:40 AM
  • Same for me, lost literally all my documents (A LOT of work and many lessons I will never can recover) on my mac this is fucking ridiculous, I always have hate microsoft a little but NOW I will never use one of their software anymore !

    I have installed visual studio code on my mac, because you know... microsoft can have change ! - -' big mistake, first and last microsoft software I will ever install !

    Why did you made a delete non-reversible ??? that's totaly stupid ! and don't say "delete changes" but "delete files" !

    and WHY, WHYYYYYY did you take the root of my documents folder by default to make a repo ???



    Tuesday, November 14, 2017 5:00 PM
  • You can still recover files added to git but not commited:

    $ echo 'oh god why' > test.file
    $ git init
    Initialized empty Git repository in /home/directory/test/reddit/.git/
    $ git add test.file 
    $ git reset --hard
    $ ls
    $ git fsck --full
    notice: HEAD points to an unborn branch (master)
    Checking object directories: 100% (256/256), done.
    notice: No default references
    missing tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
    dangling blob 1969a024cf9e4d3cb7708bc91965ee3052557b58
    $ git show 1969a02
    oh god why
    Tuesday, January 30, 2018 10:17 AM