3

I am new to Git Bash and i have accidentally called git init inside the Git Bash when the pwd was C:\. Now in my Windows Explorer there are question marks and check marks on every folder icon.

enter image description here

How can i get rid of those marks again?

I have tried several things like using git rm, but they dont work. The icons dont go away.

I thought about using git clean, but this looks like it deletes the files from my file system, which would destroy my Windows installation.

Here is the git status output: enter image description here

werkritter
  • 1,479
  • 10
  • 12
kiltek
  • 3,183
  • 6
  • 47
  • 70
  • 4
    That will have created a `c:\.git` directory. If you move that directory somewhere else I believe that will fix the problem. Assuming it does (and nothing undesirable happens) you can then delete it. – Etan Reisner Jul 20 '15 at 12:57
  • 1
    The question marks are just because the Windows shell recognizes that `C:\ ` is now a Git repository, because you created the `C:\.git` directory, and so it shows all files in that directory as untracked (i.e. not yet added to the Git repository). As Etan says, if you remove the `.git` directory it will no longer think `C:\ ` is a Git repo, and will not show its contents as untracked. – Jonathan Wakely Jul 20 '15 at 13:03
  • 3
    You might need to show hidden files or something like that to see it. Or use the Git Bash shell to remove/rename it. – Jonathan Wakely Jul 20 '15 at 13:05
  • 2
    BTW: That `git clean -f` was a damn close call. Good thing it failed with _Permission Denied_. `git clean -f` will remove untracked files - that's not what you want... – nwinkler Jul 20 '15 at 13:09

2 Answers2

10

All the git init call does is that it creates a local .git folder in the directory where you called it. In your case, that seems to be c:\.

Since there are already files and folders in your c:\, Git shows them as untracked, e.g. when using git status.

You seem to be using a tool like TortoiseGit, which integrates with Windows Explorer, hence the icon overlays.

All you need to do is to remove the c:\.git folder, and everything should be back to normal.

If you can't see the .git folder in Windows Explorer, please take a look here: No .git repository folder showing, using windows 7 - you need to enable hidden files to be shown in Explorer.

Don't use commands like git rm or git clean - they might remove some of the files and folder if used with the right command line switches.

Community
  • 1
  • 1
nwinkler
  • 52,665
  • 21
  • 154
  • 168
0

Easiest way to undo or remove the initialization of git in a directory i.e. the .git folder or in simple words git references. Navigate to that specific directory and open git bash there.

git bash will show you the name of branch written in front of it

enter image description here

in my case it's master written in round brackets

just run the following command:

rm -rf .git

and all of the references will be gone and you can start over by running the command:

git init

It'll initilize an empty git repository for you at the path specified.

Shoaib Khalil
  • 1,874
  • 17
  • 10