Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Git removed/deleted all of my files from desktop #1001

Closed
Hiram-Abiff opened this issue Jul 3, 2017 · 24 comments
Closed

Git removed/deleted all of my files from desktop #1001

Hiram-Abiff opened this issue Jul 3, 2017 · 24 comments

Comments

@Hiram-Abiff
Copy link

Hiram-Abiff commented Jul 3, 2017

I accidentally (without fully understanding what I was doing) clicked the "Create Repository" button while viewing my projects, and a git was created on my desktop. Because I had no idea how a git was used with Atom, I thought I was simply going to link Atom to an already created git. Of course, this was my fault for not reading what it said directly above the button "Initialize this project directory with a git repository"... I got way to ahead of myself, and didn't understand the possible dangers or what it meant.

After Atom tried to add everything on my desktop to the unstaged changes list, I clicked out of atom; this is when I noticed that every file on my desktop was gone, and the only thing in its place was a .git folder. I lost pictures, project files, scripts and pieces of software that was on my desktop..

The git (as far as I'm aware, as I am new to using git), did not push my content to an online repo; but then again, where are all my files then? They should have still been left untouched on my desktop, shouldn't they? But they're all gone. Is it possible the files have been uploaded somewhere? or were they deleted?

The .git folder contains about 1.75GB of content.

After opening Atom again, the files that were on my desktop and were previously shown in Atom are no longer shown anywhere under the git bars or in the project view. The only files shown are leftover folders in white, and 1 is green (a .exe that starts with the pc, so it couldn't be parsed)..

If there are any suggestions that can help me out and recover my files, I'd very very much appreciate it.

Btw, I highly recommend the git creation feature be removed/or at least relocated or improved. I can see linking an already created git, but what Atom did was completely unnecessary and should not have happened with a single click. There should be two buttons at least, one that includes "find git repository folder" and or "Create Repository". But, there should always be a warning or notice first asking if your sure you want to create the git in that location, with the locations name listed in a pop up window... I didn't even realize what directory it was going to be created in until after the fact.

And yes, I understand this primarily occurred because of my lack of knowledge in Github or Atom, but it was all too easy for what happened to actually happen anyways. and I believe more safety precautions need to be in place for people like myself. I lost a lot of content, pics, project files, text documents... a lot of stuff that I thought was somewhat safe on my desktop.

Again, I thank anyone who can help me recover my files; months of work has just disappeared, and I am lost now.

@ungb
Copy link

ungb commented Jul 3, 2017

@Hiram-Abiff, I'm not certain there's a way to get your changes back but seeing how the .git repo is very large, I wonder if you probably deleted all your files on your desktop folder using the github package. Only way I can see this happening is if you selected all files in unstaged changes and click discard changes in context menu.

We have a undo/redo feature, but from my observation, once you close atom and open back up that button disappears.

/cc @kuychaco do you know if there's a way from command line to get back files that were deleted by discarding changes through the UI then closing Atom? It seems that in Atom once you close and open atom back up the Undo Discard button is gone.

Although based on your scenario, I'm only making an assumption you clicked discard changes in the unstaged changes view since you didn't mention that. Git by itself doesn't delete anything when you click Create Repository it adds a .git folder to make it a git project

see https://git-scm.com/docs/gittutorial for more info on git.

@simurai
Copy link
Contributor

simurai commented Jul 4, 2017

@Hiram-Abiff Sorry to hear about your troubles. 😟 As @ungb mentioned, this should only have happened when doing Discard All Changes. If not, then something else went wrong.

The .git folder contains about 1.75GB of content.

The guide below maybe helps, but I only tried it on macOS. For Windows or Linux it might be different. Also before running some commands, it's probably a good idea to first backup your Desktop or make a copy of .git and save it somewhere else.

If you look inside the .git/objects/ folder, do you see lots of "2 digit" folders, like these?

screen shot 2017-07-04 at 2 24 57 pm

If so, you can try the following:

cd Desktop
git fsck --lost-found

Then under .git/lost-found/other/ you should see lots of files with long names:

screen shot 2017-07-04 at 2 34 21 pm

Unfortunately, the file names are gone, but at least you can get the files back. Might be hard to sort through and rename them if there are 100s of files. Once you recovered all files, you can delete .git.

@ungb
Copy link

ungb commented Jul 5, 2017

@Hiram-Abiff I'm going to close this issue, but please reopen this issue if you see an actual issue and can give a consistent repro on the issue. I attempted the scenario on mac and windows where I follow what you did. The files still there unless I click discard changes which is doing what's expected.

@ungb ungb closed this as completed Jul 5, 2017
@kuychaco
Copy link
Contributor

kuychaco commented Jul 5, 2017

Yeah, I second what @ungb says about the only way I can imagine this happening is if all your files were selected in the git panel and "discard changes" was selected in the context menu.

Pinging @smashwilson for his knowledge of the inner workings of "Create Repository" in case anything comes to mind

@smashwilson
Copy link
Contributor

Hmm, nothing comes to mind... "Create Repository" just shells out to git init, which should never to my knowledge touch the working copy.

@rsese
Copy link
Contributor

rsese commented Aug 3, 2017

Finally getting around to adding this report from Halp:

  • support/56d7ac9a62ee11e78abac66d2e4a95b4

Yeah, I second what @ungb says about the only way I can imagine this happening is if all your files were selected in the git panel and "discard changes" was selected in the context menu.

Another user ran into this and playing around with it, and I did find another similar way to do this but without having to select all the files in Unstaged Changes - for some project in directory project:

  1. cd project
  2. atom .
  3. From the Git tab, click Create Repository
  4. Right click on the Unstaged Changes list heading i.e.:

unstage-menu

  1. Click "Discard All Changes"

So without specifically selecting all files and selecting "Discard Changes", you can lose your files (assuming you close Atom so can no longer "Undo Discard").

Even though things are still working as expected, the feedback is that's it's relatively easy to lose a project if you're not super familiar with Git/GitHub.

@BinaryMuse
Copy link
Contributor

I'm open to dropping "Discard all changes" from the context menu. If that's really what you want, you can select them all and discard.

@simurai
Copy link
Contributor

simurai commented Aug 3, 2017

At the Mini Summit somebody ( @maxbrunsfeld? ) had the idea that "Discard all changes" would only discard modified files, but not added files. So the "Discard all changes" would have no effect in this situation.

And when you right-click on an added file, instead of saying "Discard Changes", it would say "Delete File" or "Move to Trash" to make it more clear that the file will be gone.

Tower does the ☝️ above behaviour.

@Hiram-Abiff
Copy link
Author

Hiram-Abiff commented Aug 5, 2017 via email

@technopian
Copy link

yh, just fallen foul of this as a newbie to git. desktop deleted. huff.

@rsese
Copy link
Contributor

rsese commented Mar 21, 2018

Sorry about that @technopian - did you perform the same steps as I described above in #1001 (comment)? If so, is Undo Discard available to you?

@technopian
Copy link

hi and thanks for reply - i did indeed try the tips mentioned to no avail. lives & learns, but where's the software's prior prompting/first install mention of risk? yes, accepted, t'was my fault ultimately, but this particular software i definitely expected to be in safe hands, not dangled over a precipice on first use. software designed to ensure proper control of all files, makes for super simple deletion without impact being well communicated. seems bunk to me.

@cleung30
Copy link

cleung30 commented Oct 6, 2018

@simurai I have unfortunately also fallen into this predicament and I am stuck on how to get out. I accidentally click discard changes for all the files on my desktop, but there is a transparent .git folder on my desktop with the files you mentioned. Problem is that all the files seem unreadable. Do you have any advice on how to recover them from this folder? I'm using windows btw.

@simurai
Copy link
Contributor

simurai commented Oct 19, 2018

cleung30 Problem is that all the files seem unreadable. Do you have any advice on how to recover them from this folder? I'm using windows btw.

Not sure about windows. Is it possible to move the files? Or copy them to a different place? Maybe it's unreadable because it's in the .git folder and "protected".

@rsese
Copy link
Contributor

rsese commented Oct 19, 2018

Sorry, forgot to mention here - @cleung30 reached out over email and was able to recover their files (though without the file names and extensions). They did mention that Undo Discard was available but didn't do anything.

I wasn't able to reproduce, but @cleung30 if you can reproduce that behavior with some test repository, feel free to open a new issue with the template filled out so we can take a look.

@cleung30
Copy link

@simurai thank you for your response. I was able to recover the files like @rsese mentioned. but with no name or file type. @rsese maybe try adding something to "unstaged" , discard changes, and then close atom. I've included a very useful article that i've included below and definitely would have saved 14 hours of trying to ifnd the answer online.

https://medium.com/@CarrieGuss/how-to-recover-from-a-git-hard-reset-b830b5e3f60c

@bugs181
Copy link

bugs181 commented Mar 10, 2019

Ouch! This issue just bit me hard. I must of somehow hit a hot-key combination because my project directory just deleted everything I had in .gitignore file. Unfortunately, wasn't able to recover anything from .git as it was empty. I had to go to my other backup solutions and still not sure all what I've lost in the process.

@rsese
Copy link
Contributor

rsese commented Mar 15, 2019

Ugh sorry about that @bugs181 - it seems like the exact sequence of steps aren't clear but just to confirm, do you happen to have repro steps? Or do you remember if Undo Last Discard was available?

https://flight-manual.atom.io/using-atom/sections/github-package/#discard-changes

@bugs181
Copy link

bugs181 commented Mar 15, 2019

I don't have the minute details of the repro steps but can try to connect the dots.

Platform: OSX 10.14
Github Desktop: Version before latest (1.6.3)
Directory: /Users/levi/Desktop/Projects/ProjectName

Had nearly a week of work in ProjectName (and luckily for me I had backups of this directory).

    • Created online Git repo
    • Renamed local /ProjectName to /ProjectName2
    • Cloned online Git repo into /ProjectName
    • Copied files from /ProjectName2 to /ProjectName
    • Made modifications to .gitignore, Github desktop was minimized.
    • Was pressing CMD key, and accidentally hit some other keys.
    • Watched as all files disappeared from my eyes.

For step 5. I was trying to white-list specific directories from .gitignore. It's strange because these are the files/folders that had disappeared. I had tried every undo option I could think of. None were available via Finder, Github Desktop, or Trash

@cmaginot
Copy link

cmaginot commented Jul 7, 2020

I was just orienting myself with Git and Github today and I deleted essentially all the files I had in the folder. I had no clue what I was doing and didn't even realize the files were gone until it was too late. This is not a good button and it makes it even harder to orient yourself with a software.

@manojadhav
Copy link

Try
$ git reflog
and then
$ git merge your branch_name

branch_name is denoted by a hexadecimal number, you will need to enter that particular number.

hope it helps.

@Chinamaniac
Copy link

I ran into the same problem as other users in which I accidentally deleted changes in atom. I tried running git fsck but command prompt does not recognize git and it does not work. Is there anything else I can do? I am using Windows

@mailova
Copy link

mailova commented May 8, 2021

HELP! :'(

Hello, I am very very new to coding and using Git.
I was supposed to make a repository as an assignment, somewhere in that process I closed the git app because I couldn't get to the folder I needed; I wanted to restart the process and remove whatever I had added and start with a new address from my desktop hoping that would be easier. Even more files were added and I proceeded to close the page. That is when my screen went black and everything on my desktop deleted. My background, my files, everything except a few items in the trash were gone. I was logged out of everything on my internet websites and don't know what to do to get my files and my desktop back to normal. PLEASE PRETTY PLEASE HELP! :'(

I can't find an email to contact git, so I'm hoping this helps. If not should I take my device to GeekSquad? Like I said I'm new to this world and it's giving me a beat down.

@imsanketsingh
Copy link

Thankyou so much

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests