Git - did init bare in wrong directory

500865 picture 500865 · Apr 13, 2012 · Viewed 8.5k times · Source

I ran the git --bare init in a wrong directory(in the server). I see the files branches, config, deps etc., in that directory.. How do I undo it?

Answer

GoZoner picture GoZoner · Apr 13, 2012

Since you performed a '--bare' init, there is no .git directory - instead the normal contents of the .git directory are directly in the parent directory. For example, the place where you did 'git init --bare' looks something like:

$ git --bare init
Initialized empty Git repository in /Users/ebg/test/foo/
$ ls
HEAD        config      hooks/      objects/
branches/   description info/       refs/

to undo this simply perform:

rm -rf HEAD config hooks objects branches description info refs

Of course, be careful if you already had files and directories there with those names.