I can’t find the command. I tried Googling «git ‘delete a repository'».
Coleman
5657 silver badges15 bronze badges
asked Oct 3, 2009 at 15:30
1
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.
answered Oct 3, 2009 at 15:39
7
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.
answered Dec 1, 2012 at 18:55
AzatAzat
3,7742 gold badges16 silver badges13 bronze badges
5
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.
answered Oct 3, 2009 at 15:39
rkjrkj
8,8352 gold badges29 silver badges35 bronze badges
2
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.
answered Sep 1, 2012 at 21:26
LucianNovoLucianNovo
3605 silver badges14 bronze badges
3
I can’t find the command. I tried Googling «git ‘delete a repository'».
Coleman
5657 silver badges15 bronze badges
asked Oct 3, 2009 at 15:30
1
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.
answered Oct 3, 2009 at 15:39
7
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.
answered Dec 1, 2012 at 18:55
AzatAzat
3,7742 gold badges16 silver badges13 bronze badges
5
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.
answered Oct 3, 2009 at 15:39
rkjrkj
8,8352 gold badges29 silver badges35 bronze badges
2
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.
answered Sep 1, 2012 at 21:26
LucianNovoLucianNovo
3605 silver badges14 bronze badges
3
Одна из самых распространенных систем управления версиями – Git. Ее ядро добавляет в систему ряд консольных команд, предназначенных для управления репозиториями. В самих же репозиториях хранятся важные каталоги, конфигурационные файлы, журналы и прочие связанные элементы.
Далее я расскажу, как создать, клонировать и удалить эти репозитории.
Следующие инструкции предназначены для тех, кто уже установил Git на свой сервер. Если вы еще не сделали этого, используйте руководство с GitHub, которое поможет разобраться с выполнением поставленной задачи.
Подробнее: How to install Git
Создание Git-репозитория
Сначала рассмотрим создание репозитория. Представим, что у вас уже есть папка для хранения файлов, но она еще не находится под контролем Git.
Откройте «Командную строку» (Windows) или Терминал (Linux/macOS) и перейдите по пути данной папки.
В Linux выполните команду:
cd /home/user/directory
В macOS:
cd /Users/user/directory
В Windows:
cd C:/Users/user/directory
Остается только ввести нижеуказанную команду, чтобы завершить первый этап.
Благодаря этой команде создается структура подкаталога со всеми необходимыми файлами. Кстати, все они расположены в подпапке с названием .git. Пока что проект не находится под контролем учета версий, поскольку в него добавлены только нужные элементы для работы Git. Для добавления файлов в репозиторий будем использовать git add. Команда git commit является заключительной:
git add git commit -m 'initial project version'
Теперь у вас есть Git-репозиторий со всеми необходимыми составляющими и отслеживаемыми файлами.
Комьюнити теперь в Телеграм
Подпишитесь и будьте в курсе последних IT-новостей
Подписаться
Клонирование существующего репозитория
Второй вариант создания директории для контроля версий – копирование существующего проекта с другого сервера. Это актуально, когда осуществляется доработка готового проекта или вы желаете внедрить его компоненты в свой. В этом поможет команда git clone, о которой и пойдет речь далее.
При использовании упомянутой команды вы получаете клоны всех версий файлов, а значит, можете использовать любые из них, если что-то пойдет не так. Это же пригождается, когда требуется вернуть предыдущую версию проекта, что осуществимо благодаря файлам, помещенным под версионный контроль.
Для клонирования существующего репозитория понадобится ввести git clone <url>. Пример такой команды вы видите ниже:
git clone https://github.com/rep/rep
Данная команда позволила вам получить клон всех версий указанного репозитория (в качестве примера было взято название rep). Теперь на вашем сервере создана директория с указанным названием. К ней подключена поддержка контроля версий, то есть появилась папка .git.
При использовании вышеуказанной команды репозиторий клонируется с текущим названием. Если же оно должно отличаться, используйте следующую вариацию команды:
git clone https://github.com/rep/rep myrep
Завершим этот раздел статьи описанием содержимого, которое появляется в консоли при выполнении команды. Данный вывод соответствует успешному клонированию:
Cloning into 'Git'... remote: Counting objects: 46, done. remote: Compressing objects: 100% (25/25), done. remote: Total 46 (delta 7), reused 43 (delta 4), pack-reused 0 Unpacking objects: 100% (46/46), done. Checking connectivity... done.
Удаление локального Git-репозитория
Если с созданием и клонированием репозиториев все понятно, то как быть, когда папка с проектом уже существует, но в нее нужно поместить новые данные, удалив предыдущие, или когда Git-репозиторий на сервере больше не нужен. В таком случае осуществляется стандартное удаление.
В корне каталога с проектом необходимо избавиться от папки .git, о которой уже шла речь выше. Так вы удаляете только ту информацию, которая связана с Git, но сам проект остается. В Linux через Терминал вы должны перейти к каталогу с проектом и ввести следующую команду:
Еще один вариант – удаление .gitignore и .gitmodules в случае их наличия. Тогда команда меняет свой вид на:
Остается только убедиться в отсутствии скрытой папки, которая может помешать инсталляции новой. Для этого существует простая команда ls -lah, выполнить которую необходимо с указанием того же каталога.
Только что мы разобрались с основами создания, клонирования и удаления Git-репозитория. Удачи!
When you use the git init
command, it will initialize a brand new Git repository in the same folder that the command was run in.
It will initialize in a folder called .git
in the root directory, and it will contain all the information about the repository.
In this post, we’ll learn how you can effectively undo this, and delete the repository locally.
Removing a repository locally
You can remove a Git repository created locally by git init
by simply removing the resulting .git
folder.
When this folder is removed, it will no longer be a valid Git repository, as that is what Git uses to identify a repository.
You can simply use your operating system’s file manager to remove the .git
folder by right-clicking on it and selecting Delete
.
Windows
If you’re on Windows, you can use the following command to remove the .git
folder:
rmdir .git
macOS
If you’re running macOS, you can use the following command to remove the .git
folder:
rm -rf .git
Linux
If you’re on Linux, you can use the following command to remove the .git
folder:
rm -rf .git
Regardless of your operating system, once the folder is gone, the repository will no longer be a valid Git repository.
Conclusion
In this post, we learned how to remove a Git repository locally, effectively reversing what git init
does.
Simply get rid of the resulting .git
folder, and the repository will no longer exist on your computer.
Thanks for reading!
If you want to learn about web development, founding a start-up, bootstrapping a SaaS, and more, follow me on Twitter! You can also join the conversation over at our official Discord!
-
Support Us
-
Join
-
Share
-
Tweet
-
Share
Give feedback on this page!
Delete Git repo locally
There’s not trick in terms of how to delete a Git repo locally from your computer. You just need to delete all of the content from the folder in which the Git repo was either cloned or initialized. That’s it.
Okay, maybe there is a bit of a trick. Every Git repo has a hidden folder named .git in which the DVCS tool stores all of its configuration data. If your computer hasn’t been configured to show hidden files and folders, attempts to locally delete a Git repo will fail, because the hidden .git folder will remain. Configure your computer to show local folders, delete the .git folder using your operating system’s File Explorer, the the local Git repository is removed.
Steps to delete a local Git repo
To delete a Git repository locally, follow these steps:
- Open the the local Git repo’s root folder
- Delete all of the files and folder in the Git repo’s root folder
- Delete the hidden .git folder with File Explorer or through the command line
- Run a git status command. A fatal: not a git repository error verifies that the Git repo is deleted
Command line Git repository delete
If you’re familiar with the terminal window or the DOS prompt, you can easily perform a command line Git repository delete. Just run the rm command with the -f and -r switch to recursively remove the .git folder and all of the files and folders it contains.
This Git repo remove command also allows you to delete the Git repo while allowing all of the other files and folder to remain untouched.
delete@git-repo /c/remove/repository (main-branch) $ rm -fr .git
Verify Git repo is removed
If you use the Git BASH terminal window to remove the Git repository, you will notice the name of the current Git branch is no longer listed once the Git removal command is issued.
delete@git-repo /c/remove/repository $ git status fatal: not a git repository (or any of the parent directories): .git
Furthermore, any git commands you issue will return with a fatal: not a git repository error. While errors aren’t typically the way we seek confirmation in the software development work, in this case, seeing this fatal error is proof that the local Git repository delete operation ran successfully.
The way to delete a Git repo locally is to simply remove the hidden .git folder.