Does running git init twice initialize a repository or reinitialize an existing repo?

What happens to an existing git repository when you issue git init again?

I created a repository with git init. Created a file, add, commit. Check the status (nothing to commit). Then created another file, check the status and I can see it’s untracked as expected.

  • How to accommodate multiple coding styles? (git vs. IDE)
  • How do I fix “Cannot pull into a repository with state: MERGING” in EGit?
  • Releasing a multi-module Maven project hosted in single Git repository
  • How do I prevent git push <branch> from pushing unless I am checked out on that branch?
  • Git Merge branch 'master' of https://bitbucket.org/xxx/yyy
  • Ansible 2.1.0 using become/become_user fails to set permissions on temp file
  • Then, say by mistake, I run git init again and I get Reinitialise existing Git repository message.

    Tried git status, but it shows the same. So what really happens?

    Can reinitialising an existing git repository this way be harmful or helpful? Why can we git init inside an existing repository?

  • Is there a fast way to rebase a long history of commits to master branch?
  • How to recover files from index
  • GitHub - prevent collaborators from using push -f
  • Concurrency in a GIT repo on a network shared folder
  • User who made Pull Request doesn't appear in Contributor List after merge
  • Retain author after a cherry-pick conflict
  • 3 Solutions collect form web for “Does running git init twice initialize a repository or reinitialize an existing repo?”

    From the git docs:

    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.

    This is described in the git init 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.

    Since v1.7.5 (b57fb80a7), git init in an existing repo has also allowed moving the .git directory:

    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).

    ‘Picking up newly-added templates’ means that any templates which have not already been copied from the template directory will now be copied into the existing git directory.

    ‘Moving the repository to another place’ means that, if --separate-git-dir points to somewhere else, the existing .git directory will be moved there and replaced by a link.

    Git Baby is a git and github fan, let's start git clone.