Next: , Previous: , Up: Manipulating   [Contents][Index]


6.2 Cloning Repository

To clone a remote or local repository use C, which is bound to the command magit-clone. This command either act as a transient prefix command, which binds several infix arguments and suffix commands, or it can invoke git clone directly, depending on whether a prefix argument is used and on the value of magit-clone-always-transient.

User Option: magit-clone-always-transient

This option controls whether the command magit-clone always acts as a transient prefix command, regardless of whether a prefix argument is used or not. If t, then that command always acts as a transient prefix. If nil, then a prefix argument has to be used for it to act as a transient.

C     (magit-clone)

This command either acts as a transient prefix command as described above or does the same thing as transient-clone-regular as described below.

If it acts as a transient prefix, then it binds the following suffix commands and several infix arguments.

C C     (magit-clone-regular)

This command creates a regular clone of an existing repository. The repository and the target directory are read from the user.

C s     (magit-clone-shallow)

This command creates a shallow clone of an existing repository. The repository and the target directory are read from the user. By default the depth of the cloned history is a single commit, but with a prefix argument the depth is read from the user.

C b     (magit-clone-bare)

This command creates a bare clone of an existing repository. The repository and the target directory are read from the user.

C m     (magit-clone-mirror)

This command creates a mirror of an existing repository. The repository and the target directory are read from the user.

The following suffixes are disabled by default. See (transient)Enabling and Disabling Suffixes for how to enable them.

C d     (magit-clone-shallow-since)

This command creates a shallow clone of an existing repository. Only commits that were committed after a date are cloned, which is read from the user. The repository and the target directory are also read from the user.

C e     (magit-clone-shallow-exclude)

This command creates a shallow clone of an existing repository. This reads a branch or tag from the user. Commits that are reachable from that are not cloned. The repository and the target directory are also read from the user.

User Option: magit-clone-set-remote-head

This option controls whether cloning causes the reference refs/remotes/<remote>/HEAD to be created in the clone. The default is to delete the reference after running git clone, which insists on creating it. This is because the reference has not been found to be particularly useful as it is not automatically updated when the HEAD of the remote changes. Setting this option to t preserves Git’s default behavior of creating the reference.

User Option: magit-clone-set-remote.pushDefault

This option controls whether the value of the Git variable remote.pushDefault is set after cloning.

User Option: magit-clone-default-directory

This option control the default directory name used when reading the destination for a cloning operation.

User Option: magit-clone-name-alist

This option maps regular expressions, which match repository names, to repository urls, making it possible for users to enter short names instead of urls when cloning repositories.

Each element has the form (REGEXP HOSTNAME USER). When the user enters a name when a cloning command asks for a name or url, then that is looked up in this list. The first element whose REGEXP matches is used.

The format specified by option magit-clone-url-format is used to turn the name into an url, using HOSTNAME and the repository name. If the provided name contains a slash, then that is used. Otherwise if the name omits the owner of the repository, then the default user specified in the matched entry is used.

If USER contains a dot, then it is treated as a Git variable and the value of that is used as the username. Otherwise it is used as the username itself.

User Option: magit-clone-url-format

The format specified by this option is used when turning repository names into urls. %h is the hostname and %n is the repository name, including the name of the owner.


Next: , Previous: , Up: Manipulating   [Contents][Index]