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?
While there is no undo git init command, you can undo its effects by removing the . git/ folder from a project. You should only do this if you are confident in erasing the history of your repository that you have on your local machine.
git . The --bare flag creates a repository that doesn't have a working directory, making it impossible to edit files and commit changes in that repository. You would create a bare repository to git push and git pull from, but never directly commit to it.
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With