Page 1 of 1

Deleting a Local GitHub Repository

Posted: Thu Jul 21, 2022 5:26 am
by l6vibq
how-to-remove-files-and-folders-using-linux-command-line.jpg
When a user clones a Git repository from Github using the command git clone <url>, they get a copy of the remote repo on their local computer so that they can work on it on their current working directory where the repo got cloned without directly making changes on the remote repository.

If you want to delete a local Github Repository that was cloned from to local computer without touching or making any changes to the Remote GitHub repository then follow the commands below:

Step 1: Go into your project file
cd <project_name>

rm -rf <repository_folder>.git
With the deletion of the ‘.git’ file, this will delete the .git file that contains a log of the commit history, its information, and also remote repository address from the working directory. We can think of this deletion as when we do git init to initialize the current working directory as Git directory, with the above command we are just reverting it back to not being a Git directory.

Then what about the files and folder in the present working directory?

This has to be deleted using the following set of command:

Go to the directory where the project is present (Note: Don’t go inside the project file).
rm -rf <folder_name>