How to Delete a Git Repository: Local, Remote, and Everything In Between
Deleting a Git repository sounds straightforward — until you realize there are at least three different things you might mean by "delete." You could be removing the local copy from your machine, wiping a remote repository from a hosting platform like GitHub or GitLab, or doing both. Each scenario involves different steps, different consequences, and a very different level of reversibility.
What Actually Makes Up a Git Repository
Before deleting anything, it helps to understand what you're dealing with. A Git repository is essentially a folder that contains two things: your working files (the actual project content) and a hidden .git directory. That .git folder is where Git stores the entire history of your project — every commit, branch, tag, and configuration.
When people say "delete a Git repository," they usually mean one of these:
- Remove the
.gitfolder only — strips version control from the folder but leaves your files intact - Delete the entire local repository folder — removes everything: files and Git history
- Delete a remote repository — removes the repo from GitHub, GitLab, Bitbucket, or wherever it's hosted
These are meaningfully different operations, and the right one depends entirely on what you're trying to accomplish.
How to Delete a Local Git Repository
Option 1: Remove Just the Git Tracking (Keep Your Files)
If you want to stop tracking a project with Git but keep the actual files, you only need to delete the .git directory. On macOS or Linux, open a terminal in your project folder and run:
rm -rf .git On Windows using Command Prompt:
rmdir /s /q .git After this, the folder becomes a plain directory — no version history, no branches, no remotes. Your files are untouched. This is useful when you want to reinitialize a repo from scratch or simply stop using Git for a project.
Option 2: Delete the Entire Local Repository
If you want the project gone entirely, just delete the whole folder like you would any other directory.
- macOS/Linux terminal:
rm -rf your-project-folder - Windows: Delete the folder through File Explorer or use
rmdir /s /q your-project-folderin Command Prompt - GUI file managers: Move the folder to the trash and empty it
⚠️ This is permanent once the trash is emptied. There's no Git "undo" for a deleted local repo — the history lives inside that .git folder, and once it's gone, it's gone.
How to Delete a Remote Repository
Remote repositories hosted on platforms like GitHub, GitLab, or Bitbucket are deleted through the platform's settings interface — not from the command line.
Deleting a Repository on GitHub
- Go to the repository page on GitHub
- Click Settings (the gear icon near the top right of the repo)
- Scroll to the bottom of the General settings page to find the Danger Zone
- Click Delete this repository
- Type the repository name to confirm, then click the confirmation button
GitHub requires you to type the repo name as a deliberate friction step — it prevents accidental deletions. Once confirmed, the repository and all its issues, pull requests, and history are removed from GitHub's servers.
Deleting a Repository on GitLab
- Navigate to the project page
- Go to Settings → General
- Expand the Advanced section at the bottom
- Click Delete project
- Type the project name to confirm
GitLab may enforce a delayed deletion period depending on your account type and settings — this is a safety net that gives you a window to cancel.
Deleting a Repository on Bitbucket
- Open the repository
- Go to Repository settings
- Scroll to Delete repository under the General section
- Confirm the deletion
What Happens to Forks and Collaborators
Deleting a remote repository doesn't automatically delete forks — copies that other users have made of your repo. Those forks become independent repositories. If your project had collaborators or was part of an organization, they may still have local clones, but they'll lose access to the remote.
This is an important variable: if you're a solo developer cleaning up an old side project, deletion is clean and simple. If you're managing a shared codebase or an open-source project with active forks, the downstream effects are much broader.
The Difference Between Deleting and Archiving
Deleting is irreversible (or at least difficult to reverse). Archiving is a softer alternative available on platforms like GitHub — it makes a repository read-only and signals that it's no longer actively maintained, without destroying any history or data.
For repositories you might want to reference later, or that others may still be using, archiving is worth considering as a middle ground.
Variables That Affect Your Approach
| Factor | What It Changes |
|---|---|
| Solo vs. team project | Team repos may have open PRs, issues, and dependencies to consider |
| Public vs. private repo | Public deletion affects anyone who's starred, forked, or linked to it |
| Active CI/CD pipelines | Deleting a repo can break automated workflows connected to it |
| Package registries | Published packages (npm, PyPI, etc.) may reference the repo URL |
| Submodules | Other repos pointing to this one as a submodule will break |
🗂️ For developers working within organizations or contributing to shared infrastructure, any of these factors can make what looks like a simple cleanup into something that needs coordination first.
Local Deletion vs. Remote Deletion: They're Independent
One point that trips people up: deleting a local repository does not affect the remote, and vice versa. If you rm -rf your local clone, the GitHub version still exists. If you delete the GitHub repo, your local clone still works — it just has no remote to push to or pull from.
If your goal is complete removal, you need to do both steps explicitly. The two operations are entirely independent of each other, and Git won't warn you if you only do one.
Your specific situation — whether you're a solo developer, part of a team, dealing with a public or private repo, or working with connected services — determines which of these steps apply, which order makes sense, and how much caution is warranted before you commit to the deletion.