So you want to remove git from a project folder and keep the files but lose the history and tracking. Fine. This is a practical git cleanup guide that covers backing up work first and then nuking the .git folder so your project becomes a plain old folder again. Useful for one time cleanups or when local git history is embarrassing.
First rule of devops club is do not destroy things without a backup. Run pwd
or check your file explorer to make sure you are in the project root. Then copy the folder or compress it to an archive. Backups are boring until they save your career.
Find out what git thinks of your folder with git status
. That will list tracked and untracked files. If you have work you want to keep add and commit it or stash it. Examples of safe git commands are:
git status
git add .
git commit -m "backup commit"
# or stash if you do not want a commit
git stash save "backup"
Committing makes restoring later simpler. Stashing is fine for a quick save if you plan to reintroduce git soon.
Deleting the .git folder removes all git history and local tracking but leaves your working files intact. On macOS and Linux run rm -rf .git
. On Windows use Command Prompt with rmdir /s .git
or PowerShell with Remove-Item -Recurse -Force .git
. If you are nervous rename the folder instead with mv .git .git-backup
so you can restore history later.
Renaming is reversible and cheap. If you discover you need commit history or remotes later just restore the folder and resume being tracked. If you are absolutely sure you want to delete history then remove the backup to free space.
If your local repo had a remote and you want to drop that binding run git remote remove origin
after restoring a temporary git folder or simply edit the .git config if you know what you are doing. Removing remotes prevents accidental pushes to a remote you meant to forget.
Run git status
from the project root to confirm you no longer have a git repo. You should see a message about not being a git repository or an error. You can also list hidden files to make sure .git
is gone with ls -la
or your file explorer. If the goal was to fully delete local history the absence of the .git folder means success.
pwd
git add
and git commit
or git stash
rm -rf .git
or Windows equivalentgit remote remove origin
if neededgit status
and checking for a missing .gitThis tutorial kept the commands basic and safe for most local git cleanup tasks. If you are working in a team or with shared remotes be extra cautious. If you want to permanently delete history from a remote that is a different and more complicated process. For quick local git removal this method will do the job and spare you a week of awkward questions.
I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!
This is a dedicated watch page for a single video.