运行git init是否会初始化一个存储库或重新初始化现有的repo? [英] Does running git init twice initialize a repository or reinitialize an existing repo?
问题描述
当您再次发布 git init
时,现有的git存储库会发生什么变化? 我创建了一个存储库, git init
。创建一个文件,添加,提交。检查状态(没有提交)。然后创建另一个文件,检查状态,我可以看到它没有像预期的那样跟踪。
然后,我错误地说,我再次运行
git init
,然后我得到重新初始化现有的Git存储库消息。 试过 git status
,但它显示相同。那么究竟发生了什么?
可以通过这种方式重新初始化现有的git存储库是否有害或有帮助?为什么我们可以在现有的仓库中 git init
?
git 文档:
在现有的资源库中运行git init是安全的。它不会覆盖已经存在的东西。重新运行git init的主要原因是挑选新添加的模板。
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.
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?
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.
这篇关于运行git init是否会初始化一个存储库或重新初始化现有的repo?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!