Sato Sato - 5 months ago 27
Git Question

Is it saft to git clone to the same git directory

for example, first there is no

directory, i
git clone

`git clone test`

then after some push/pull, I do it again:

`git clone test`

will the second clone damage the local test repo?


because i do
in a one-time script, this script is supposed to run one time, ideally, but if it fails, or on other reason, it might be ran multiple times, so
will be ran multiple times too. if its not ok, i will do a
rm -rf test

Answer Source

As we can read in the git docs:

Clones a repository into a newly created directory


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.

Replying to your question: yes, it's safe to run git clone multiple time. The repository won't be damaged.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download