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?
Asked
Active
Viewed 9,447 times
2 Answers
32
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.

GoZoner
- 67,920
- 20
- 95
- 145
6
If you did it on directory which wasn't previously set up as git repository, you can just remove .git folder (assuming you're using linux):
rm -rf .git
Otherwise, if directory already contained repository (.git directory), than git init would have no effect (i.e. git log will show the same commits before and after git init).

BluesRockAddict
- 15,525
- 3
- 37
- 35
-
5UPDATE: GoZoner's answer (http://stackoverflow.com/a/10135410/754042) is actually the correct one, my answer is only applicable if git init was run without --bare switch. – BluesRockAddict Apr 13 '12 at 05:11