I can't find the command. I tried Googling "git 'delete a repository'".
4 Answers
Delete the .git
directory in the root-directory of your repository if you only want to delete the git-related information (branches, versions).
If you want to delete everything (git-data, code, etc), just delete the whole directory.
.git directories are hidden by default, so you'll need to be able to view hidden files to delete it.
-
14This WOULD delete the files if they aren't in use, but so long as Git locks them, it won't work so this does not answer "how to delete a local repo".– rainabbaMar 18, 2014 at 7:42
-
19@rainabba, Why would Git be locking them in the first place? Close your Git app.– PacerierOct 20, 2015 at 11:13
-
4How do you 'close your Git app'? Anyway, it's seemingly about permission rather than app lockdown. In Ubuntu:
sudo rm -r directory
. Aug 18, 2016 at 15:26 -
1
-
8@JozemiteApps If there is no .git directory, there is no repository. Run
ls -a
to see hidden files. Jan 27, 2017 at 18:44
To piggyback on rkj's answer, to avoid endless prompts (and force the command recursively), enter the following into the command line, within the project folder:
$ rm -rf .git
Or to delete .gitignore and .gitmodules if any (via @aragaer):
$ rm -rf .git*
Then from the same ex-repository folder, to see if hidden folder .git is still there:
$ ls -lah
If it's not, then congratulations, you've deleted your local git repo, but not a remote one if you had it. You can delete GitHub repo on their site (github.com).
To view hidden folders in Finder (Mac OS X) execute these two commands in your terminal window:
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
Source: http://lifehacker.com/188892/show-hidden-files-in-finder.
-
5It's not only to avoid prompts, rm -rf was necessary for me otherwise rm would not delete files and complain: rm: cannot remove `.git/objects/pack': Directory not empty– ÉtienneApr 24, 2013 at 13:38
-
2Yes, -r is for recursive and -f is for force. So you are forcing and doing recursive deletion.– AzatMay 7, 2013 at 21:53
-
2I'd actually suggest deleting
.git*
to also remove.gitignore
and.gitmodules
if any.– aragaerMay 7, 2013 at 22:14 -
-
Thanks) its work great ,for windows in project folder run rm -rf .git Nov 28, 2019 at 5:14
In the repository directory you remove the directory named .git and that's all :). On Un*x it is hidden, so you might not see it from file browser, but
cd repository-path/
rm -r .git
should do the trick.
-
8you'll want to use "rm -rf .git" or you'll be pressing "y" to confirm for every single file in the directory. Sep 24, 2019 at 13:21
That's right, if you're on a mac(unix) you won't see .git in finder(the file browser). You can follow the directions above to delete and there are git commands that allow you to delete files as well(they are sometimes difficult to work with and learn, for example: on making a 'git rm -r ' command you might be prompted with a .git/ not found. Here is the git command specs:
usage: git rm [options] [--] ...
-n, --dry-run dry run
-q, --quiet do not list removed files
--cached only remove from the index
-f, --force override the up-to-date check
-r allow recursive removal
--ignore-unmatch exit with a zero status even if nothing matched
When I had to do this, deleting the objects and refs didn't matter. After I deleted the other files in the .git, I initialized a git repo with 'git init' and it created an empty repo.
-
1That's not 100% true. I'm on Mac OS X and I can see
.git
and other hidden/system folder easily (e.g.,.DS_Store
). All you need to do is to configure Finder. Here is how: lifehacker.com/188892/show-hidden-files-in-finder.defaults write com.apple.finder AppleShowAllFiles TRUE
and thenkillall Finder
.– AzatMay 7, 2013 at 21:57 -
Yes that's right, you can configure finder to show hidden files, as well as you can configure editors to show hidden folders. The lesson here is that everything that begins with a '.' is a usually a hidden folder/file. May 8, 2013 at 6:13
-
1Actually, for OS X you can use the key combination Shift-Command-[period] to show or hide hidden files or directories - much easier than entering those commands into terminal! Jul 19, 2018 at 6:31