How to Delete Git Repository Created with Init

If you created a repository with the git init command and now want to delete the entire repository, then this is the right place. In this tutorial, we will show how you can delete a repository created with git init by just running command line. As Git keeps all the files in the .git directory, we can just remove it and solve the problem. But the methods are different for Linux and Windows.

Solution for Linux

The following command line will delete the Git Repository and undo the changes made by git init:

rm -rf .git

Solution for Windows

Deleting a repository and undo the changes for Windows differs from the one for Linux. Run the following to delete the repository:

rmdir .git

If the repository has subfolders, then execute:

rmdir /s .git

The git init Command

The git init command generates a new, empty Git Repository or to reinitialize an existing one. A repository is a storage of the project files, which makes it possible to save code versions and have access to them. This command creates a .git subdirectory which includes the metadata, like subdirectories for objects and template files to generate a new repository.


Do you find this helpful?

Related articles