Deleting a Git repository means removing the hidden .git folder that tracks your project's history

When you delete a Git repository, you are removing the version control system from your project — not the files themselves. Git stores all its tracking information in a hidden folder called .git. Deleting this folder stops Git from monitoring changes, but your actual project files remain untouched unless you explicitly remove them too.

The safest approach is to delete only the .git folder first, verify your project files are still there, and then decide whether to delete the entire project directory. This two-step process prevents accidentally losing work you meant to keep.

Key Takeaways

  • Deleting the .git folder stops version control but leaves your project files intact.
  • On Mac and Linux, use rm -rf .git in your project directory; on Windows, delete the .git folder through File Explorer or use rmdir /s .git in Command Prompt.
  • Always verify your project files still exist after removing .git before deleting anything else.
  • If you want to keep a backup of your repository history, push it to a remote location like GitHub before deleting the local copy.

Delete the .git folder on Mac or Linux

Open the terminal and navigate to your project directory using cd. For example, if your project is in a folder called my-project on your desktop, type cd ~/Desktop/my-project and press Enter.

Once you are in the project directory, type rm -rf .git and press Enter. The -rf flags tell the system to remove the folder and everything inside it without asking for confirmation. The .git folder is now deleted, and Git will no longer track changes to this project.

To confirm the folder is gone, type ls -la and press Enter. You should no longer see a .git folder in the list. Your project files remain exactly as they were.

Delete the .git folder on Windows

Open File Explorer and navigate to your project folder. At the top of the window, click the View menu and check the box next to "Hidden items" so you can see the .git folder, which is hidden by default.

Right-click the .git folder and select Delete. Windows will move it to the Recycle Bin. If you want to permanently remove it instead of sending it to the Recycle Bin, hold Shift while pressing Delete, then confirm the permanent deletion.

Alternatively, open Command Prompt, navigate to your project directory, and type rmdir /s .git. Press Enter and confirm when prompted. This removes the folder and all its contents without moving it to the Recycle Bin.

Verify your project files are still there

After deleting .git, check that your actual project files — your code, documents, images, or whatever you were working on — are still in the folder. On Mac or Linux, type ls in the terminal to list the contents. On Windows, look at the folder in File Explorer.

If your files are present and the .git folder is gone, the deletion was successful. Git is no longer tracking this project, but your work is safe. You can now decide whether to delete the entire project folder or keep it as a regular folder without version control.

Back up your repository before deleting if you need the history

If you have pushed your repository to GitHub, GitLab, or another remote location, your commit history and all previous versions are already backed up there. Deleting the local .git folder does not affect the remote copy.

If you have not pushed to a remote location and you want to preserve your commit history, do that before deleting .git. Open the terminal or Command Prompt in your project directory and type git remote add origin [your-remote-url], then git push -u origin main (or master if that is your default branch). This uploads your entire history to the remote location.

Once the push is complete, you can safely delete the local .git folder knowing your history is preserved elsewhere.

Delete the entire project folder if you no longer need it

If you want to remove the project completely — not just stop tracking it with Git — delete the entire project directory. On Mac or Linux, navigate to the parent directory and type rm -rf my-project (replace my-project with your folder name). On Windows, right-click the folder in File Explorer and select Delete.

This step is optional. Many people delete only the .git folder and keep the project files as a regular folder for reference or future use without version control.

Understand what happens after deletion

Once the .git folder is deleted, Git commands like git status, git log, and git commit will no longer work in that directory. If you try to run a Git command, you will see an error message saying "fatal: not a git repository".

The project folder becomes a regular directory with no version control. You can still edit and use the files, but Git will not track changes. If you later decide you want version control again, you can initialize a new repository by typing git init in that directory. This creates a fresh .git folder and starts tracking from that point forward, but it will not recover the old commit history.

Frequently Asked Questions

Can I recover a deleted .git folder?

If you deleted the .git folder but did not empty your Recycle Bin or Trash, you can restore it. On Windows, open the Recycle Bin, right-click the .git folder, and select Restore. On Mac, open Trash, find the .git folder, right-click it, and select Put Back. If the Recycle Bin or Trash has been emptied, recovery is very difficult and requires specialized data recovery tools.

What if I delete .git but want to keep my project files?

Your project files are completely separate from the .git folder. Deleting .git leaves all your code, documents, and other files untouched. You can continue using and editing them as a regular folder without version control.

Does deleting a local .git folder affect my repository on GitHub?

No. Your remote repository on GitHub, GitLab, or another service is independent of your local .git folder. Deleting the local folder does not change anything on the remote. Your commit history and all pushed code remain safe there.

How do I know if a folder is a Git repository?

Look for a .git folder inside the directory. On Mac and Linux, type ls -la in the terminal. On Windows, enable "Hidden items" in File Explorer's View menu. If you see a .git folder, it is a Git repository. If not, it is a regular folder.

Can I delete .git from a project I am still working on?

Yes, but you will lose the ability to see your commit history and revert to previous versions. Before deleting, push your repository to a remote location so your history is backed up. After that, you can safely delete .git and continue working on the files as a regular project folder.