本文翻译自:How do I delete a local repository in git? [duplicate]
This question already has an answer here: 这个问题在这里已有答案:
I can't find the command. 我找不到命令。 I tried Googling "git 'delete a repository'". 我尝试使用谷歌搜索“git'删除存储库'”。
#1楼
参考:https://stackoom.com/question/6LsE/如何在git中删除本地存储库-重复
#2楼
That's right, if you're on a mac(unix) you won't see .git in finder(the file browser). 没错,如果你在mac(unix)上,你将不会在finder(文件浏览器)中看到.git。 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: 您可以按照上面的说明删除,并且有git命令也允许您删除文件(它们有时难以使用和学习,例如:在制作'git rm -r'命令时,可能会提示您a .git / not found。这是git命令规范:
usage: git rm [options] [--] ... 用法: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. 删除.git中的其他文件后,我使用'git init'初始化了一个git repo并创建了一个空的repo。
#3楼
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: 为了捎带rkj的答案 ,为了避免无休止的提示(并递归强制命令),在项目文件夹中的命令行中输入以下内容:
$ rm -rf .git
Or to delete .gitignore and .gitmodules if any (via @aragaer): 或者删除.gitignore和.gitmodules(如果有的话)(通过@aragaer):
$ rm -rf .git*
Then from the same ex-repository folder, to see if hidden folder .git is still there: 然后从相同的ex-repository文件夹中查看隐藏文件夹.git是否仍然存在:
$ ls -lah
If it's not, then congratulations, you've deleted your local git repo, but not a remote one if you had it. 如果不是,那么恭喜你,你已经删除了你当地的git仓库,但如果你拥有它,则不会删除远程仓库。 You can delete GitHub repo on their site (github.com). 您可以在他们的网站上删除GitHub仓库(github.com)。
To view hidden folders in Finder (Mac OS X) execute these two commands in your terminal window: 要在Finder(Mac OS X)中查看隐藏文件夹,请在终端窗口中执行以下两个命令:
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
Source: http://lifehacker.com/188892/show-hidden-files-in-finder . 资料来源: http : //lifehacker.com/188892/show-hidden-files-in-finder 。
#4楼
Delete the .git
directory in the root-directory of your repository if you only want to delete the git-related information (branches, versions). 如果您只想删除与git相关的信息(分支,版本),请删除存储库根目录中的.git
目录。
If you want to delete everything (git-data, code, etc), just delete the whole directory. 如果要删除所有内容(git-data,code等),只需删除整个目录即可。
.git directories are hidden by default, so you'll need to be able to view hidden files to delete it. .git目录默认是隐藏的,因此您需要能够查看隐藏文件才能将其删除。
#5楼
In the repository directory you remove the directory named .git and that's all :). 在存储库目录中,删除名为.git的目录 ,这就是全部:)。 On Un*x it is hidden, so you might not see it from file browser, but 在Un * x上它是隐藏的,所以你可能无法从文件浏览器中看到它,但是
cd repository-path/
rm -r .git
should do the trick. 应该做的伎俩。