Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Git init in wrong directory? How to recover? (theoretical situation)

This is completely theoretical, but I'm new to Git and Linux so I want to know.

If I accidentally manage to do git init inside e.g Desktop or Home directory, how to prevent any possible disaster from happening?

git init creates hidden .git directory where it's config-files are so is it just so simple to remove this hidden directory?

Would the directory it was in become "normal" again instead of git master branch?

Or would removing .git cause some problems? Like the directory trying to identify itself as git repository but cannot find the configs?
by

1 Answer

Kajalsi45d
If you run git init in a directory which isn’t already a git repository, removing .git will reverse all the effects of git init without any other side-effects.

Login / Signup to Answer the Question.