Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to undo misoperation of Reinitialized existing Git repository

Tags:

I just ran git init on an already existing git repo.
The result is Reinitialized existing Git repository

How can I undo this?
Thanks!

like image 732
Honghe.Wu Avatar asked Oct 16 '13 07:10

Honghe.Wu


People also ask

Why Reinitialized existing git repository in?

Running git init in an existing repository is safe. It will not overwrite things that are already there. The primary reason for rerunning git init is to pick up newly added templates (or to move the repository to another place if --separate-git-dir is given).

How do I re initialize a repository?

You can do this, and it will not affect your remote repos at all (you'd have to delete those seperately if that is what you want). delete on local, than checkout the repo again ;) @Thilo - exactly just remove the . git directory, run git init, remove all your remote repos and push again.


1 Answers

No need - it is quite safe to do. From the documentation:

Running git init in an existing repository is safe.  It will not overwrite things that are already there.  The primary reason for rerunning git init is to pick up newly added templates. 

The templates are files such as the sample hooks and example files that are part of git. If you have updated git since creating the repo and these files have changed, they will not be updated - only new files will be added. Since none of these files are actually 'active', this should be entirely safe.

like image 138
Oliver Matthews Avatar answered Oct 15 '22 03:10

Oliver Matthews