Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 531
naught101 Avatar asked Mar 15 '12 00:03

naught101


People also ask

Is downloading a repo the same as cloning it?

When you download the repo it just gives you all the source files with no . git so you dont have the repo. When you clone you get a copy of the history and it is a functional git repo.

What does cloning a git repository do?

Git clone is used to copy an existing Git repository into a new local directory. The Git clone command will create a new local directory for the repository, copy all the contents of the specified repository, create the remote tracked branches, and checkout an initial branch locally.

What is the difference between cloning and forking a repo?

Any public Git repository can be forked or cloned. A fork creates a completely independent copy of Git repository. In contrast to a fork, a Git clone creates a linked copy that will continue to synchronize with the target repository.

Can I just copy a git repository?

Yes you can, but there's no need to copy the full working tree. You can copy just the . git folder without the working tree (i.e. as a "bare" repo) and then checkout the latest working tree on the other machine.


1 Answers

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.)

like image 87
Amber Avatar answered Sep 21 '22 16:09

Amber