-2

I was trying to attach a project to a GIT repository yesterday and it deleted my whole folder.

I executed the command like this:

git remote add origin https://domain/DefaultCollection/projectName

As you can see I missed the "_git" in the URL above, it should have been:

git remote add origin https://domain/DefaultCollection/_git/projectName

So after executing the first command I deleted the .git folder to make it right in another try, but once I did that the whole project was gone and I lost a whole week of work.

If someone can help me telling me where the files can be or if git maybe hidden them somewhere, it will be really appreciated.

To clarify: I didn't execute the second command because after deleting the .git folder everything was gone.

Felipe Correa
  • 654
  • 9
  • 23
  • So making a mistake with a tool and asking for help is enough to get a down vote? What a community... – Felipe Correa Jul 02 '15 at 15:11
  • No, blaming your tools is enough to get a downvote. What you said happened in the title didn't happen. Try actually asking a question without presupposing an answer. – jthill Jul 03 '15 at 14:13
  • 1
    "I deleted the .git folder" <-- that was your repository. – jthill Jul 03 '15 at 17:23
  • @jthill I know what the .git folder is in the GIT system, I know the importance. What I don't get is how deleting that folder deleted all the content of the project that was part of my HD file system. That's the whole deal. I didn't even get to do a commit or a push, but my code should be there. Anyway, I was able to recover the code from an old backup and rewrote some missing classes. – Felipe Correa Jul 05 '15 at 07:49
  • @jthill also, can you point me the part where I said it was a problem that GIT generated? Can you tell me where did I blame the tool? – Felipe Correa Jul 05 '15 at 07:52
  • In the title, where you said git remote add deleted your project, and in the first sentence, where you said I was trying to attach a project to a GIT repository yesterday and it deleted my whole folder. – jthill Jul 05 '15 at 15:10
  • @jthill the action in the middle of the process of trying to do what I was trying to do deleted my folder. I never said or implied it was GIT fault. That's part of your interpretation which is clearly wrong as I focused in the steps I did and recognized my errors refering to the URL and everything else. – Felipe Correa Jul 06 '15 at 05:40

1 Answers1

1

I was trying to attach a project to a GIT repository yesterday and it deleted my whole folder.

git didn't probably didn't delete the information, you probably did when you subsequently deleted the .git folder.

If you have successfully git pushed to a repository before deleting the .git folder, you can get back information from the repository that you pushed by "cloning" it. If there was no repository pushed to before you removed the .git folder, git can't help you and you'll need one of the general backup/restore kinds if solutions you might have available.

To retrieve from a repository that you have previously "git push"ed to, run git clone https://domain/DefaultCollection/_git/projectName or whatever the correct URL is. Best to do this under a new directory, say in /tmp. Then check things out and if this is what you expect, rename the old folder if it is still there. And move the newly checked-out directory (a git project) to the parent of the old location.

Important. When reporting results make sure to not only give your conclusion but also both the input that you typed and the output you received in response to the input. That helps the people trying to help you. You may think it obvious what went on from your description, but sometimes there is other information that you don't understand that can be obtained by giving the facts rather than your impression of them. And giving facts is also the simplest more fool-proof thing to do.

Lastly, if it is not obvious now, deleting everything in .git is generally a mistake. That directory starts with "." precisely to make it hard for people to casually change it. A good habit to get into is to instead of deleting folders, move them. Alternatively backups such as time machine on OSX are cool too.

rocky
  • 7,226
  • 3
  • 33
  • 74
  • It didn't work, it says **fatal: Not a git repository (or any of the parent directories): .git**. I tried the command with the wrong and the correct url. Didn't work. – Felipe Correa Jul 02 '15 at 14:29
  • When you gave the correct URL, you get output. So as I said, list *both* the input you gave and the output you get. "Didn't work" is vague. There is some expectation of what you were expecting which is unspecified. When you give the correct URL you get something. – rocky Jul 02 '15 at 14:32
  • I don't know if you are not reading me right. The output was the message I wrote in bold. That was the output for the both inputs I tried that were exactly as you told me with the wrong url and the correct url. – Felipe Correa Jul 02 '15 at 15:08
  • Sorry that should have been "clone" not "checkout". And when that works you should at least see the message "Cloning into ...". Again, cut and paste both input and output. – rocky Jul 02 '15 at 15:16
  • I tried it: git clone url. This is the output: Cloning into 'mienvigado'... Username for Password for remote: Microsoft (R) Visual Studio (R) Team Foundation Server remote: Receiving objects: 100% (988/988), 40.06 MiB | 356.00 KiB/s, done. Resolving deltas: 100% (224/224), done. Checking connectivity... done. – Felipe Correa Jul 02 '15 at 15:24
  • It cloned a .git folder, but none of the project files so it seems like the repository is empty. – Felipe Correa Jul 02 '15 at 15:25