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

前端 未结 4 938
傲寒
傲寒 2020-11-27 13:33

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

I created a repository with git init. Created a file, add, commi

相关标签:
4条回答
  • 2020-11-27 13:57

    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.

    0 讨论(0)
  • 2020-11-27 13:57

    it's mean that you already initialized the git. because you already upload a file on github from this path. you check the path then a folder is created by name of .git. That is why you don't requried again to initialized git. you can go to direct next step

    git add .

    Git folder

    0 讨论(0)
  • 2020-11-27 14:07

    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.

    0 讨论(0)
  • 2020-11-27 14:07

    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.

    0 讨论(0)
提交回复
热议问题