This guide provides the process of deleting a local repository in Git.
How Do I Delete a Local Repository in Git?
To remove the Git local repository, first, we will navigate to the Git root directory and create a local repository. Then, list the content of the root directory. Lastly, run the “$ rm -fr <repo-name>” command to delete the Git local repository.
Now, implement the above-discussed instructions for better understanding!
Step 1: Navigate to Git Root Directory
First, move to the Git root directory using the following command:
Step 2: Create Git Local Repository
Now, execute the “mkdir” command to create a new Git local repository:
Step 3: List Root Directory Content
Next, view the list of Git root directory content to ensure if the new repository is created using the following command:
As you can see that, a new repository named “Demo18” is created successfully:
Step 4: Delete Local Repository
Execute the “rm” command with the “-fr” option and specify the name of the local repository you want to delete:
Step 5: Verify Deleted Repository
Lastly, view the list of Git root directory to ensure the deleted Git local repository:
According to the below output, the deleted “Demo 18” local repository does not exist in the root directory:
That’s it! We have offered the easiest way to remove a local repository in Git.
Conclusion
To delete the Git local repository, first, navigate to the Git root directory and create a local repository. Then, list the content of the root directory. Now, execute the “$ rm -fr <repo-name>” command to delete the Git local repository. Lastly, run the “$ ls” command to ensure the deleted local repository. This guide demonstrated the easiest method to delete a local repository in Git.