Deleting a Local Git Repo
Last updated 2026-09-15 · 3 notes · 3 tags
Tags: git github delete
Use this when you no longer need a local clone on one device but want to keep the GitHub repository and all other device copies unchanged.
Note: Deleting a local repository folder does not delete the GitHub repository or affect clones on other devices. The checks below protect you from losing work that exists only on this device.
1. Open the local repository
cd ~/projects/project-folder
Note: Replace
project-folderwith the actual path to the repository you plan to delete.
2. Check for uncommitted changes or untracked files
git status
- Safe result:
working tree clean - Action if clean: Continue to the next check.
- If changes are listed: Commit and push them, or copy/stash anything you want to preserve before deleting the folder. This includes untracked files.
3. Check for unpushed local commits
git log @{u}..HEAD --oneline
- Safe result: Blank output. No commits are ahead of this branch's configured upstream.
- If commits are listed: They exist only on this device until you push them. Run
git pushif you want them on GitHub and available to other devices.
Note: If Git reports that the branch has no upstream, this check cannot confirm that the local commits exist on GitHub. Inspect the branch and remote with
git branch -vvandgit remote -v, then push or preserve the work before deleting anything.
4. Delete the local folder
From the folder's parent directory, run:
cd ~/projects
rm -rf -- project-folder
Warning: Replace
project-foldercarefully and verify the path before runningrm -rf. This permanently deletes the local files and cannot be undone from the shell.
You can also delete the folder with your file manager after completing the checks.
5. Verify the remote is unchanged
Deleting the clone does not send a command to GitHub. Other devices can continue using their existing clones, and the GitHub repository remains available online.
Note: If you later need the project again, clone it from GitHub onto the device instead of trying to recover the deleted folder.
Common mistakes
- Do not skip the untracked-files check in
git status; untracked work is not included in a commit. - Do not treat a missing upstream as proof that all commits were pushed.
- Do not run
rm -rfuntil you have confirmed that the path names the intended repository.
This project captures ideas, decisions, and lessons I’ve learned while building with AI. It aims to help non-technical users understand and use these tools effectively. I also use AI at times to improve or refine the content.
Readers should use the commands and instructions here with care. The creator accepts no responsibility for system damage, data loss or other consequences resulting from their use.