What's the difference between cloning and copying a git repo?

naught101 picture naught101 · Mar 15, 2012 · Viewed 10.8k times · Source

The same question exists for mercurial, and I'm wondering how this applies to git? In particular, I'm interested in cases where there are two local repos, and copying between servers using rsync or such.

Also, if the original repo is itself cloned from, say gitorious, and I copy it, then gitorious will still exist as a remote (tracked by the master branch) in the copy, right? Does this happen if the copy is cloned instead?

Answer

Amber picture Amber · Mar 15, 2012

Cloning a repository gives you a copy of that repository and configures the original repository as a remote.

Copying a repository just gives you a copy of that repository. (Though you can of course just add the remote definition afterwards via git remote add.)


Copying a repository copies its .git/config file, and thus its remotes. Cloning a repository does not copy the config file, and thus the remotes are not shared. (The repository that was cloned from is set as the origin remote in the resulting clone.)