I have Initialized a git repository and have made some commit in that now for some reason I do not want to track any files in it and want to remove git from my local repo. Is there some way I can Uninitialize it?
6 Answers
git stores all the repository related data in a folder named ".git" inside your repository folder. So you just want to keep your files but change it into a "not-git-repository". Warning: this is irreversible!
cd path/to/repo
rm -rf .git
The only files that might remain are hidden ".gitignore" files (but only if you added them yourself or using some tool like eclipse). To remove them:
find . -name ".gitignore" | xargs rm

- 35,025
- 12
- 111
- 136
-
-
Please also tell me if that remove will be permanent or still I can undo it? – Naseer Mar 20 '14 at 17:28
-
2Warning: Before running `rm -rf .git`, make sure that this is really the repo you want to "uninitialize". That command will irreversibly (well, [almost irreversibly](http://www.linux.org/threads/undelete-files-on-linux-systems.4316/)) destroy all of your repo's history, leaving only the files currently in the wroking directory. – Ajedi32 Mar 20 '14 at 18:05
-
@khan `-r` means 'recursive'. It's required for deleting folders. `-f` means "force". It's required for deleting protected files. – Ajedi32 Mar 20 '14 at 18:07
-
My repo seems to be corrupted. It constantly sees a deleted file that is too large to push. I used this method to leave the files in place but uninitialize, and then re-initialize using `git init`. It re-initiaizes the old tracking system and history even after the deletion. So this doesn't work.. – rocksNwaves Mar 24 '20 at 19:15
-
I've been tracking some files on folderA I've moved those files to folderB. All files in folderB are represented in red in pyCharm. I do not have .git folder in folderB and running. What can I do here? – haneulkim Apr 05 '21 at 03:48
-
@Ambleu don't post a question in a comment. First look if you can find an answer online, if not ask a new question. – Chris Maes Apr 06 '21 at 06:15
-
@Ajedi32 Looks like your link got updated. It's now: https://linux.org/threads/undelete-files-on-linux-systems.8784/ – rmutalik Dec 13 '21 at 14:24
Just deleting the .git
directory stored in the repository will pretty much do it.

- 311
- 5
- 16

- 307
- 1
- 7
-
>pretty much is relevant here. I'm working on a unique case, but rm -rf *, .git, everything. a wipe of the directory to ls -a producing "." and ".." only, followed by "git log" yields previous commits – ChootsMagoots May 06 '22 at 01:24
Go to "File Explorer Options" in the control panel, there go to "View" and check the option that allows you to see the hidden folders.
Then go to the folder where you want to un-initialize the git repository and you will find a folder called ".git" (it will be slightly faded since it's a hidden folder).
Deleting this folder will do the trick.

- 123
- 2
- 13
go to the folder where you initialized git ,check on the hidden files we can see .git file deleting that file solves our problem

- 11
- 1
-
2Its a folder, not a file. Also, the same answer was provided by another user. – Mansoor Oct 31 '20 at 16:40
Sometimes this may be a folder permission issue so the comments above definitely will help.
If you are using a linux distro try this command
chown -R <current_user> <repo_folder>
For example in my devcontainers I used with VSCode i had this issue and running
chown -R node .
solve this issue.
If the . and .. owners of the folder when you run ls -la
are different from files in the folder, git evaluates this and needs specific override to initialise it so if that may be correct then you will need to use this command below to add an exception to git
git config --add safe.directory 'project_path' --global
Hope that help :)

- 185
- 1
- 9
I put rm -rf .git
in the terminal then
I removed .gitignore
from one of my project's folders and added it to the root but it didn't work.
ctrl + shift + p
> reload window
didn't ignore the +3K
changes in my source control tree either.
Surprisingly, when I closed vscode and re-open it again it successfully responded to the changes.

- 124
- 2
- 4