I encountered a bug that made me lose tons of work (see this thread). I am new to git, but this is probably not a desired behavior, espacially that the manipulation I did is typically something you would do when you discover Git. I did it using Atom so I will describe the steps to reproduce it on Atom. However, I don't think that's related to Atom. Here is how to reproduce it:
Step 1. Create a new project in Atom (My Project)
Step 2. In the project create a folder (Folder 1)
Step 3. In that project create a source file (aFile.jl) and write "This is the file in folder 1" in it, save
Step 4. Duplicate Folder 1 twice, name the new folders Folder 2 and Folder 3 respectively.
Step 5. Change the text in Folder 2/aFile.jl to "This is the file in folder 2", save. Do the same in folder 3 but with a 3.
Step 6. In the Git tab, initialize a new repository. Your project tree should now look like this:
> My Project
> Folder 1
> Folder 2
> Folder 3
Step 7. In the Git tab, the three files should be awaiting in unstaged changes. Click on the ... next to it and discard all changes. If you now check the tree the "aFile.jl" files disapeared.
Step 8. In the Git tab, click on the same ... and undo last discard. This will bring back the files.
However, if you check their contents, the "aFile.jl" files now have the same content. Which means that the undo pick a single file and wrote it in every folder. I know that Step 7. is stupid, but I did it thinking Git was "safe" for my files. This is not an expected behaviour. If this is not a bug and you know a way of restoring the three files in the state they were at Step 6. I would be eternally grateful for a solution. If it is a bug, then someone may want to fix that.
Solved! Solved! Go to Solution.
Yes, this is a bug. Please open an issue at https://github.com/atom/github/issues/new with the same information and we'll look into it.
Unfortunately, this has nothing to do with git. Because the changes were unstaged, git was never tracking those files and therefore wasn't protecting them. For future reference, in order for git to protect your files or their contents, you have to:
Typically, I do the above multiple times a day so that I only lose at most a couple hours of work.
Additionally, if you want to learn more about exactly how git works and protects your files, I highly recommend Git from the Bottom Up by John Wiegley.
But you are correct, the undo discard feature in Atom's github package shouldn't have behaved that way.