Removing a repository removes all files in folder
Asked by timbellomo:

This may be completely obvious to people with more git experience, but while removing a repository that I created in error (without even the initial commit having been done), I caused the deletion of all of the contents of the folder in which the repository was created.

Perhaps this is how git is intended to work, but it's not what I expected. My naiviety led me to believe that removing the repository would simply delete any versioned changes, leaving on disk the current "working copy" of the individual files.

Is this how removing a repository (not just a bookmark) is supposed to work? Should it have deleted all files in that same directory (even though they hadn't been committed to the repo yet)?

\*edited title for clarity


Answers:
author: stevestreeting
body: When you remove a bookmark, you are given 2 choices - just remove the bookmark, or remove the bookmark AND delete the repository on disk. The default option is to simply remove the bookmark, not to delete anything on disk. Here's a screenshot of the Windows version for example, but the behaviour is the same on Mac: <http://screencast.com/t/Do6UoAdfpOy8>

![](http://screencast.com/t/Do6UoAdfpOy8)

comments: author: timbellomo
body: Right -- I chose the latter, because I actually wanted to delete the newly-created-in-error repo.

Consider the following:

I'm working on myfantasicproject for several weeks. I've got a decent chunk of files and folders that I've been working with. I suddenly realize, "Shame on me! I should be using git!" I go into SourceTree, and create a new repository in the top-level directory of my project. Yay!

Before continuing, though, I realize that, well, maybe it would be better if I managed some of these pieces in separate repositories, say one for the client, and one for the server, and not just one monolithic repo for the whole folder. So I want to remove the repo, and create my two smaller ones. When prompted, I say, "yeah, don't just remove the bookmark from SourceTree; actually just delete that repo -- I made it in error; it doesn't even really contain anything (I haven't committed anything)." Boom goes the directory.

I'm not asserting that they're should be any changes made, just giving some feedback on my confusion. If you decide that it's clear and doesn't need any changes, I respect that. As I said, I'm a git beginner, so perhaps the terminology isn't as familiar to me as it should be.

Thanks for your consideration.


author: stevestreeting
body: Ah, I see - I didn't appreciate you'd interpreted it as just referring to the .git folder rather than the source folder. Perhaps this can make this clearer in the message.


author: stevestreeting
body: I've added a new secondary warning dialog (Windows version right now), which only occurs when the repo you've asked to delete has uncommitted changes (modified files or untracked files). Hope that helps avoid this misunderstanding in future.

![New dialog](http://content.screencast.com/users/sjstreeting/folders/Jing/media/401bc956-1192-4afe-ba5f-d98c90a93595/2013-04-18_1807.png)


author: timbellomo
body: Thanks! It may be overly cautious, but to me (given the high risk scenario) necessary.


author: James Rimmer
body: Hi... while this may have been true at the time of this writing, in the current latest release of SourceTree for Mac (1.9.8) the options are not as shown in the screenshot you provided; how do I delete \*ONLY\* the bookmark, and not anything else, from SourceTree?


author: Plystire Gryatto
body: Why is this even an option? SourceTree should not be responsible for DELETING the source, opted for or not. As with the OP, I thought the same thing, and here I am with 5% of my files remaining only because I had them open in editors and was able to save them back to disk from memory. Like, wow... fucking wow... even providing the option is stupid. Make the lazy devs delete their own files. Why?! WHY??? Not even to the trash can/recycle bin... just gone. Just fucking GONE. I don't care if there's a warning three times, do you have any clue how desensitized people are to confirmation boxes?  
Would it not make more sense to only delete, you know, the shit you're responsible for? AKA, ENTRIES to source control, not the source itself? Leave the files alone. Remove the source CONTROL, not the SOURCE.

And stop calling it "the repository" when you actually mean "your SOURCE will be GONE". You need to be **clear** about this. Don't use lingo. Don't use big words. Tell the user what is about to happen and don't be coy about it.

"You opted to blah blah blah blah", that is what people see in a confirmation box like that one (which I myself didn't even see).

......... all because I wanted to be safer using source control. Months fucking gone! Thank you for ruining my holidays, Atlassian.


author: John Buskmiller
body: Just wanted to let you know that this foolishly designed option just wasted a day of my work as well.

When I ask a program to delete a repository and remove it from the disk, I expect it to remove its portion. Why would I ever want a tool responsible for saving versions of files to delete the actual files themselves? I can delete things on my own, thanks. Thanks for saying "delete the repository" when you actually mean delete everything. Especially considerate with modern SSDs and making sure it doesn't wind up in the Recycle bin!


author: Aaron
body: Wow, literally just lost weeks of work. This is the stupidest feature I've ever seen.

Handle the git operations, not file operations, holy shit. This is ridiculous. I'm pissed as shit right now.


author: timbellomo
body: Right -- I chose the latter, because I actually wanted to delete the newly-created-in-error repo.

Consider the following:

I'm working on myfantasicproject for several weeks. I've got a decent chunk of files and folders that I've been working with. I suddenly realize, "Shame on me! I should be using git!" I go into SourceTree, and create a new repository in the top-level directory of my project. Yay!

Before continuing, though, I realize that, well, maybe it would be better if I managed some of these pieces in separate repositories, say one for the client, and one for the server, and not just one monolithic repo for the whole folder. So I want to remove the repo, and create my two smaller ones. When prompted, I say, "yeah, don't just remove the bookmark from SourceTree; actually just delete that repo -- I made it in error; it doesn't even really contain anything (I haven't committed anything)." Boom goes the directory.

I'm not asserting that they're should be any changes made, just giving some feedback on my confusion. If you decide that it's clear and doesn't need any changes, I respect that. As I said, I'm a git beginner, so perhaps the terminology isn't as familiar to me as it should be.

Thanks for your consideration.