How to Delete Git Repository Created with Init
Solution for Linux
To undo the changes made by git init you should delete the git repository. Follow the steps below to make the job done.
- Open the Terminal by typing the Ctrl + Alt + T
- Next type the following command line which will delete the git repository and undo the changes made by git init:
rm -rf .git
Solution for Windows
The method to undo the changes for Window differs from other operating systems. Here are the steps to follow.
- Open the Run prompt by pressing Windows + R.
- Then, type cmd and press Shift+Ctrl+Enter to provide administrative privileges.
- Run the following to delete the repository and press Enter:
If the repository has subfolders, then execute:
rmdir /s .git
Solution for Mac OS
In this section, we will demonstrate to you two ways of detecting the hidden files and deleting them in Mac OS.
- In the framework of the first method, first, you should open the terminal and run the code below:
defaults write com.apple.finder AppleShowAllFiles 1 && killall Finder
Then, you should type cmd + SHIFT +. to display hidden files in Finder.
Then, you should also type cd, drop your git repository folder from Finder to the Terminal window, and press return.
And, finally, you can delete them by just moving them to trash.
- In the framework of the second method, first, you should navigate to the root folder of the repository and run the command below:
rm -rf .git
The git init Command
The git init command generates a new, empty git repository or reinitializes 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.