Git

How to Fully Delete a Git Repository

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:

$ cd "C:\Users\nazma\Git\mari_khan"

 

Step 3: Initialize Directory

Initialize the Git local repository by utilizing the “git init” command:

$ git init

 

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:

$ git clone https://github.com/GitUser0422/Linux-repo.git

 

Step 5: List Directory Content

Now, list the content of the Git repository:

$ ls -la

 

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:

$ rm -fr Linux-repo

 

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:

$ ls -la

 

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.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.