[英]Is it safe to clone to the same git directory
For example, first there is no test
directory, I git clone
: 例如,首先没有
test
目录,我git clone
:
`git clone git@github.com:test/test.git test`
Then after some push/pull, I do it again: 然后,在进行一些推/拉操作后,我再次执行此操作:
`git clone git@github.com:test/test.git test`
Will the second clone damage the local test repo? 第二个克隆会损坏本地测试存储库吗?
REASON: 原因:
I clone
in a one-time script, which is supposed to run one time, ideally. 我
clone
了一次脚本,理想情况下应该运行一次。 But if it fails, or another reason, it might be run multiple times, so clone
will be run multiple times too. 但是,如果失败或其他原因,它可能会运行多次,因此
clone
也将运行多次。 If it's not ok, I will do an rm -rf test
first. 如果还不行,我将首先进行
rm -rf test
。
As we can read in the git docs: 正如我们可以在git docs中阅读的:
Clones a repository into a newly created directory
将存储库克隆到新创建的目录中
and 和
Cloning into an existing directory is only allowed if the directory is empty
仅当目录为空时才允许克隆到现有目录
In your case, cloning into an already cloned directory just won't work. 就您而言,克隆到已经克隆的目录将不起作用。
In your script you can handle/test the return code of git command and perform proper actions if git clone fails or not. 在您的脚本中,您可以处理/测试git命令的返回码,并在git clone失败或失败时执行适当的操作。
Replying to your question: yes, it's safe to run git clone multiple time. 回答您的问题:是的,多次运行git clone是安全的。 The repository won't be damaged.
存储库不会被损坏。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.