Take the 2-minute tour ×

I want to remove git tracking from a project's directory. What is the correct method to do this? Can I do a shell command such as:

rm -rf .git

from my projects directory or is there a way to do this as a git command.

I used this project to learn git and realize I made some mistakes early on in the project with moved, renamed and deleted files. I'd like to remove all git tracking and start fresh with git init.

share|improve this question
Depending on how bad the mistakes were, you might actually want to do an interactive rebase of the whole thing and just squash together a ton of commits early on, but save more recent good history. –  Jefromi Jan 21 '11 at 0:21
This should be the proper answer. Jefromi, add it as a full answer and I'll up-vote. –  Adam Dymitruk Jan 21 '11 at 0:40
There should be a big warning for new Git users (such as myself) with blueberryfields answer. That "git clean -xdf" it will permanently delete the actual files/directories in the git repo. As in my case....most of my files in my user directory as I was just trying to get rid of my repo and traces of it. –  zigloo99 Jun 13 '11 at 15:12
add comment

4 Answers

up vote 60 down vote accepted

All the data git uses info is stored in .git/ , so removing it should work just fine. Of course, make sure that your working copy is in the exact state that you want it, because everything else will be lost.

From there, you can run git init to create a fresh repository.

share|improve this answer
add comment

rm -rf .git should suffice. That will blow away all git-related info.

share|improve this answer
add comment

Consider git-archive.

share|improve this answer
add comment

It's not a clever choice to move all .git* by hand, particularly when these .git files hidden in sub-folders just like my condition: when I installed Skeleton Zend 2 by composer+git, there are quite number of .git files created in folders and sub-folders.

I tried 'rm -rf .git' on my Github shell, but the shell can not recognize the parameter '-rf' of Remove-Item.

www.montanaflynn.me introduces following shell command to remove all .git files one time, recursively! it's working really!

find . | grep .git | xargs rm -rf
share|improve this answer
Perfect! This worked really well. +1 –  Sebastian Dwornik Jan 22 at 13:56
add comment

Your Answer


