How to undo git init on an already existing repository?

Question:

In the folder with git, I accidentally clicked on git init , as a result, now when I do git status , all the files are displayed as changed.

In git log last commits remain. How do I undo a git init command?

Answer:

If you just accidentally created a repository, then you need to delete the .git folder in the root. This will completely destroy the repository and, of course, undo what git init did. Through the * nix console, this is done like this:

rm -r .git

Если же Вы сделали git init в уже существующем репозитории, то бояться нечего:

Running git init in an existing repository is safe. It will not overwrite things that are already there. The primary reason for rerunning git init is to pick up newly added templates (or to move the repository to another place if –separate-git-dir is given).

Scroll to Top