0

I accidentally did git init on my system32 file.

What should I do to undo that? With some research, I stumbled across the rm dir/s
command but I'm worried that would delete the actual files off my computer.

If anyone could help me with that it would be great.

  • `git init` creates a subdirectory called `.git` or perhaps `_git` on Windows. If this directory didn't exist before, it should be safe to remove. Perhaps create a temporary directory and run `git init` there to have a fresh one to compare against. – tripleee Mar 20 '22 at 08:24

1 Answers1

2

If a Git repository already existed in the location in which you ran git init, the git init command did nothing.1 In this case it will have printed a message containing the word reinitialized, and you should do nothing.

If git init did create a repository, all it did was create a .git directory and populate it with an initial empty database (technically several databases, but you don't need to worry about that yet). The git log command will show that there are no commits yet (by giving an error, in old version of Git, or by saying "no commits yet" in current versions). In this case, you can simply remove the .git directory entirely before you do anything else. This will remove the empty Git databases along with the .git directory (or "folder" if you prefer that term).


1Technically, during a reinitialization, if you've updated your Git version or added or changed your system templates, this might update some of the internal files, including "hooks". But this is quite rare in practice: almost always, a "re-initialization" is just a superficial verification that the repository is in fact a Git repository.

torek
  • 448,244
  • 59
  • 642
  • 775
  • Is there any way I could contact you on discord? I did not really understand your point here. – Tareq El-Sayyed Mar 20 '22 at 08:26
  • The point is: see whether you actually created a new repository or not. If so, remove the new repository; if not, do nothing. (I'm not generally on Discord.) – torek Mar 20 '22 at 08:31