Git is an independent versioning control system primarily used for handling large projects. Especially when multiple persons are working on a similar project simultaneously, they can create, add, update, and delete files and folders without hassle on this platform. However, there can be a scenario where you need to delete a complete Git repository at once.
In this manual, we will provide the procedure of fully removing a Git repository.
How to Fully Delete a Git Repository?
To fully delete a Git repository, we will first navigate to the Git directory and clone the remote repository. Then, display the directory content. Lastly, execute the “$ rm -fr <repo-name>” command to achieve the corresponding purpose.
The stated whole procedure is given below.
Step 1: Launch Git Bash
Open the “Git Bash” with the help of the “Startup” menu:
Step 2: Move to Git Directory
Execute the “cd” command to navigate to the Git directory:
Step 3: Initialize Directory
Initialize the Git local repository by utilizing the “git init” command:
Step 4: Clone Git Remote Repository
Run the “git clone” command to clone the remote Git repository and connect it with Git local repository using its remote repo URL:
Step 5: List Directory Content
Now, list the content of the Git repository:
According to the below output, our Git directory contains the following files and folders:
Step 6: Delete Git Repository
Finally, execute the “rm” command with “-fr” flag and specify the repository name:
Here, “-f” flag is used to remove the non-existing/hidden files arguments forcefully, and the “-r” is utilized for deleting directory and its content recursively:
Step 7: Verify Deleting Operation
Now, execute the “ls” command to verify that our Git repository is deleted or not:
As you can see, our Git directory no longer contain “Linux-repo” repository:
We have elaborated the easiest way of fully deleting a Git repository.
Conclusion
To fully delete a Git repository, navigate to the Git directory and clone the remote repository using the “$ git clone <repo-URL>” command. Then, run the “$ ls -la” command to check the content list. Next, delete the Git repository using the “$ rm -fr <repo-name>” command. Lastly, verify the deleting process by checking the content of the directory. This manual explained the method of fully deleting a Git repository.