Removing a local Git checkout or its metadata after checking worktrees, backups, and unsaved changes.

Delete Local Git Repo: Choose What to Keep

First decide whether to remove only Git’s metadata or the entire local checkout. The first choice leaves ordinary project files on disk; the second removes the directory and its contents. Neither action deletes the remote repository. Before removing a local Git repository, verify its path and save any work that exists only on your machine.

Check the Repository Path and Local Data

Open a terminal in the checkout and inspect the repository before deleting anything:

git rev-parse --show-toplevel
git status --short --branch
git worktree list
git remote -v

The first command identifies the working-tree root; compare it with the exact directory you intend to change. If Git reports no working tree, stop and investigate the location. The status lists staged and unstaged changes and ordinary untracked files. Ignored files do not normally appear there, so inspect them separately before removing a folder. Review local commits and branches that may not exist on the remote, and check submodules or other nested repositories separately.

To delete local Git repo data safely, make a verified backup of the files and history you need. A remote is not necessarily a complete backup: unpushed commits, local branches, stashes, ignored files, and uncommitted edits may exist only locally. Copy the relevant data elsewhere or use your team’s approved backup process, then confirm that the copy is readable.

Check for Linked Worktrees

A linked worktree shares repository history and configuration with the main worktree. Its top-level .git is commonly a file pointing to administrative data elsewhere, rather than a self-contained directory. Removing the main repository’s metadata can disrupt its linked worktrees. Use the list above to identify every path and preserve any work you need in each one.

To remove a clean linked worktree, run the following from another worktree of the same repository, substituting the exact path shown by the list:

git worktree remove /path/to/linked-worktree

Git normally refuses to remove a worktree with uncommitted changes or untracked files. Preserve that work and resolve the condition before proceeding. The main worktree cannot be removed with this command. See the Git worktree documentation for details and special cases.

Keep Files but Remove Git History

For a standalone main checkout whose .git is a directory and has no linked worktrees that depend on it, removing that directory disconnects the files from their local Git history. Use your file manager to reveal hidden items, verify the exact .git directory inside the intended project, and remove only that directory. Do not apply this procedure to a linked worktree or a checkout with an external Git directory.

The working files, including ignored and untracked files, remain. Local commits, branches, configuration, and stashes stored in that metadata are lost unless backed up elsewhere. A .gitignore file remains as an ordinary file. Git’s history commands no longer work for this checkout after its metadata is gone.

Remove the Entire Checkout

If you want to remove a local Git repository together with its files, first confirm the backup and the root path. Close tools using the folder, move to its parent directory in your file manager, and remove the exact project folder. This also removes untracked and ignored content inside it. Review nested repositories and linked worktrees before deleting a main checkout; they may have separate data or shared dependencies.

After removing only metadata, confirm the project files remain and inspect Git’s response from the directory. Git can discover a parent repository, so check the reported top-level path rather than assuming any successful status refers to the old checkout. After removing the whole folder, confirm the exact path is absent. If a remote exists, inspect it independently through its normal interface: these local actions do not alter its branches or stored files.