Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it safe to edit source in a repo while the repo is being cloned by another client?

One of my other machine is cloning a repo on my host machine, and I want to multitasking by making changes on the host repo.

Is this going to be safe?

like image 512
kakyo Avatar asked Nov 23 '25 07:11

kakyo


2 Answers

Yes, cloning a repository doesn't look at the working copy at all. Otherwise bare repositories could not be cloned.

Even if you make changes to the actual repository with operations like commit or reset, it is still safe. The clone might be slightly out of date when it completes, but that's no different than if you made the changes right after the clone completed.

like image 193
qqx Avatar answered Nov 24 '25 23:11

qqx


Cloning is a read only operation on the repo you are cloning. So there is no danger. Further, the operations are very atomic in git and always backed by SHA1 integrity checks. So if the clone is grabbing a reference and the reference changes during the clone, the clone will continue with the value it grabbed initially. To understand this more, google "directed acyclic graph" to see how this works. Simplicity of the structure is what makes Git as successful as it is.

like image 30
Adam Dymitruk Avatar answered Nov 24 '25 21:11

Adam Dymitruk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!