

If you know youâre going to remove the origin repository, you can use git repack -a in the clone to force it to copy all the objects it needs into its own database. Itâs important to keep in mind, though, that the clone is now dependent on the origin repository to function if the origin is not accessible, Git may abort, complaining that its object database is corrupted because it canât find objects that used to be there.

New objects you create in the clone are added to its own database the clone never modifies the originâs database via this link. Initially, the object database of the clone is completely empty, because all the objects it needs are in the origin. Rather than either copy or link files between the origin and clone repositories, this simply configures the clone to search the object database of the origin in addition to its own. With the long form you can also give a TCP port number for the server, e.g., ssh://:2222/foo.Īn even faster method when cloning a local repository is the -shared option. You can specify the SSH program to use with the environment variable GIT_SSH (the default is, unsurprisingly, ssh). If the path is relative (no leading slash), then it is usually relative to the home directory of the login account on the server, though this depends on the SSH server configuration. Git will also automatically use SSH if you use the ssh URL scheme ( ssh://), or give the repository as this uses SSH to run git upload-pack on the remote side. Git supports a number of transport schemes natively to access remote repositories, including HTTP, HTTPS, its own git protocol, FTP, FTPS, and rsync. You can specify the remote repository with a URL as shown, or with a simple path to a directory in the filesystem containing a Git repository. For example, foo stays foo, but foo.git and bar/foo also become foo. If you give a second argument, Git will create a directory with that name for the new repository (or use an existing directory, so long as itâs empty) otherwise, it derives the name from that of source repository using some ad hoc rules. You can view and manipulate remotes with git remote a repository can have more than one remote with which it synchronizes different sets of branches.Īfter cloning the remote repository, Git checks out the remote HEAD branch (often master) you can have it check out a different branch with -b branch, or none at all with -n: $ git clone We call the first repository a âremoteâ (even if it is in fact on the same host), and by default, this remote is named origin you can change this with the -origin (-o) option, or with git remote rename later on. The git clone command initializes a new repository with the contents of another one and sets up tracking branches in the new repository so that you can easily coordinate changes between the two with the push/pull mechanism.
