How to use git clone

How to use git clone

Git clone

Description

The git clone is a git command, which creates a clone/copy of an existing repository into a new directory. It is also used to create remote-tracking branches for each branch in the cloned repository. It is the most common command which allows users to obtain a development copy of an existing central repository.

How to use git clone. Смотреть фото How to use git clone. Смотреть картинку How to use git clone. Картинка про How to use git clone. Фото How to use git clone

The git clone usage

The git clone initializes a new Git repository in the team-project folder on your local machine and fills it with the contents of the central repository. After that, you can cd into the project starting modification of files, commitment of snapshots, and interaction with other repositories.

Cloning to a certain folder

You should make a clone of the repository at into the folder called on the local machine.

Cloning a certain tag

Difference Between git init and git clone

Configuration Options of Git Clone

Configuration options are the tools you need for making Git work the way that suits best to you or your team. The most common ones are presented below:

Git URLs

Git has its own URL syntax. It is used for transferring remote repository locations to Git commands. Git URLs are important because git clone is mostly used on remote repositories.

Git URL protocols

The Git protocol is unique to Git. It is a special daemon that runs on port (9418) providing a service similar to SSH but without any authentication.

The advantage of the Git protocol is a fast transfer. The Git protocol has also some disadvantages: the absence of authentication and difficulty of the protocol configuration.

Secure Shell (SSH) is a network protocol, which helps to login from one computer to another securely. In most cases, SSH access to servers is configured by default. It’s necessary to establish credentials with the hosting server before connecting.

SSH is the only network protocol, which can be easily read from and write to. SSH has many other advantages such as easy configuration, secure access (all data transfer is encrypted and authenticated), and data compactness before its transfer. The disadvantage of SSH is that it doesn’t support anonymous access to the Git repository. You can find more information about SSH keys on our SSH key section.

HTTPS

HTTPS stands for HyperText Transfer Protocol. This protocol is mostly used to transmit HTML data above the Internet. Git is configured to share information with HTTPS.

One of the advantages of HTTPS is set up simplicity. It doesn’t require a lot of resources on the server as well. It encrypts the content transfer. Corporate firewalls are set up to allow traffic through the port thus making HTTPS one of the commonly used protocols.

The main disadvantage is inefficiency for the client because it takes a lot of time to clone or fetch from the repository.

Local

Local is a basic protocol in which the remote repository is in another directory on disk. It is used when all the team members have access to a shared file system. Shared file system allows you to clone, push to, and pull from a local repository. The path to the repository can be used as the URL for cloning a repository like this to an existing project.

How to use git clone

Check your version of git by running

SYNOPSIS

DESCRIPTION

After the clone, a plain git fetch without arguments will update all the remote-tracking branches, and a git pull without arguments will in addition merge the remote master branch into the current master branch, if any (this is untrue when «—single-branch» is given; see below).

This default configuration is achieved by creating references to the remote branch heads under refs/remotes/origin and by initializing remote.origin.url and remote.origin.fetch configuration variables.

OPTIONS

Operate quietly. Progress is not reported to the standard error stream.

Run verbosely. Does not affect the reporting of progress status to the standard error stream.

No checkout of HEAD is performed after the clone is complete.

When given, and the repository to clone from is accessed via ssh, this specifies a non-default path for the command run on the other end.

Specify the directory from which templates will be used; (See the «TEMPLATE DIRECTORY» section of git-init[1].)

Set a configuration variable in the newly-created repository; this takes effect immediately after the repository is initialized, but before the remote history is fetched or any files checked out. The key is in the same format as expected by git-config[1] (e.g., core.eol=true ). If multiple values are given for the same key, each value will be written to the config file. This makes it safe, for example, to add additional fetch refspecs to the origin remote.

Create a shallow clone with a history after the specified time.

Create a shallow clone with a history, excluding commits reachable from a specified remote branch or tag. This option can be specified multiple times.

After the clone is created, initialize and clone submodules within based on the provided pathspec. If no pathspec is provided, all submodules are initialized and cloned. This option can be given multiple times for pathspecs consisting of multiple entries. The resulting clone has submodule.active set to the provided pathspec, or «.» (meaning all submodules) if no pathspec is provided.

All submodules which are cloned will be shallow with a depth of 1.

Instead of placing the cloned repository where it is supposed to be, place the cloned repository at the specified directory, then make a filesystem-agnostic Git symbolic link to there. The result is Git repository can be separated from working tree.

The number of submodules fetched at the same time. Defaults to the submodule.fetchJobs option.

The (possibly remote) repository to clone from. See the GIT URLS section below for more information on specifying repositories.

The name of a new directory to clone into. The «humanish» part of the source repository is used if no directory is explicitly given ( repo for /path/to/repo.git and foo for host.xz:foo/.git ). Cloning into an existing directory is only allowed if the directory is empty.

GIT URLS

In general, URLs contain information about the transport protocol, the address of the remote server, and the path to the repository. Depending on the transport protocol, some of this information may be absent.

Git supports ssh, git, http, and https protocols (in addition, ftp, and ftps can be used for fetching, but this is inefficient and deprecated; do not use it).

The native transport (i.e. git:// URL) does no authentication and should be used with caution on unsecured networks.

The following syntaxes may be used with them:

How to use git clone

Check your version of git by running

SYNOPSIS

DESCRIPTION

After the clone, a plain git fetch without arguments will update all the remote-tracking branches, and a git pull without arguments will in addition merge the remote master branch into the current master branch, if any (this is untrue when «—single-branch» is given; see below).

This default configuration is achieved by creating references to the remote branch heads under refs/remotes/origin and by initializing remote.origin.url and remote.origin.fetch configuration variables.

OPTIONS

Operate quietly. Progress is not reported to the standard error stream.

Run verbosely. Does not affect the reporting of progress status to the standard error stream.

No checkout of HEAD is performed after the clone is complete.

Fail if the source repository is a shallow repository. The clone.rejectShallow configuration variable can be used to specify the default.

Initialize the sparse-checkout file so the working directory starts with only the files in the root of the repository. The sparse-checkout file can be modified to grow the working directory as needed.

When given, and the repository to clone from is accessed via ssh, this specifies a non-default path for the command run on the other end.

Specify the directory from which templates will be used; (See the «TEMPLATE DIRECTORY» section of git-init[1].)

Set a configuration variable in the newly-created repository; this takes effect immediately after the repository is initialized, but before the remote history is fetched or any files checked out. The key is in the same format as expected by git-config[1] (e.g., core.eol=true ). If multiple values are given for the same key, each value will be written to the config file. This makes it safe, for example, to add additional fetch refspecs to the origin remote.

Create a shallow clone with a history after the specified time.

Create a shallow clone with a history, excluding commits reachable from a specified remote branch or tag. This option can be specified multiple times.

After the clone is created, initialize and clone submodules within based on the provided pathspec. If no pathspec is provided, all submodules are initialized and cloned. This option can be given multiple times for pathspecs consisting of multiple entries. The resulting clone has submodule.active set to the provided pathspec, or «.» (meaning all submodules) if no pathspec is provided.

All submodules which are cloned will be shallow with a depth of 1.

Instead of placing the cloned repository where it is supposed to be, place the cloned repository at the specified directory, then make a filesystem-agnostic Git symbolic link to there. The result is Git repository can be separated from working tree.

The number of submodules fetched at the same time. Defaults to the submodule.fetchJobs option.

The (possibly remote) repository to clone from. See the GIT URLS section below for more information on specifying repositories.

The name of a new directory to clone into. The «humanish» part of the source repository is used if no directory is explicitly given ( repo for /path/to/repo.git and foo for host.xz:foo/.git ). Cloning into an existing directory is only allowed if the directory is empty.

GIT URLS

In general, URLs contain information about the transport protocol, the address of the remote server, and the path to the repository. Depending on the transport protocol, some of this information may be absent.

Git supports ssh, git, http, and https protocols (in addition, ftp, and ftps can be used for fetching, but this is inefficient and deprecated; do not use it).

The native transport (i.e. git:// URL) does no authentication and should be used with caution on unsecured networks.

The following syntaxes may be used with them:

How to use git clone

Check your version of git by running

SYNOPSIS

DESCRIPTION

After the clone, a plain git fetch without arguments will update all the remote-tracking branches, and a git pull without arguments will in addition merge the remote master branch into the current master branch, if any (this is untrue when «—single-branch» is given; see below).

This default configuration is achieved by creating references to the remote branch heads under refs/remotes/origin and by initializing remote.origin.url and remote.origin.fetch configuration variables.

OPTIONS

Operate quietly. Progress is not reported to the standard error stream.

Run verbosely. Does not affect the reporting of progress status to the standard error stream.

No checkout of HEAD is performed after the clone is complete.

When given, and the repository to clone from is accessed via ssh, this specifies a non-default path for the command run on the other end.

Specify the directory from which templates will be used; (See the «TEMPLATE DIRECTORY» section of git-init[1].)

Set a configuration variable in the newly-created repository; this takes effect immediately after the repository is initialized, but before the remote history is fetched or any files checked out. The key is in the same format as expected by git-config[1] (e.g., core.eol=true ). If multiple values are given for the same key, each value will be written to the config file. This makes it safe, for example, to add additional fetch refspecs to the origin remote.

Create a shallow clone with a history after the specified time.

Create a shallow clone with a history, excluding commits reachable from a specified remote branch or tag. This option can be specified multiple times.

After the clone is created, initialize and clone submodules within based on the provided pathspec. If no pathspec is provided, all submodules are initialized and cloned. This option can be given multiple times for pathspecs consisting of multiple entries. The resulting clone has submodule.active set to the provided pathspec, or «.» (meaning all submodules) if no pathspec is provided.

All submodules which are cloned will be shallow with a depth of 1.

Instead of placing the cloned repository where it is supposed to be, place the cloned repository at the specified directory, then make a filesystem-agnostic Git symbolic link to there. The result is Git repository can be separated from working tree.

The number of submodules fetched at the same time. Defaults to the submodule.fetchJobs option.

The (possibly remote) repository to clone from. See the GIT URLS section below for more information on specifying repositories.

The name of a new directory to clone into. The «humanish» part of the source repository is used if no directory is explicitly given ( repo for /path/to/repo.git and foo for host.xz:foo/.git ). Cloning into an existing directory is only allowed if the directory is empty.

GIT URLS

In general, URLs contain information about the transport protocol, the address of the remote server, and the path to the repository. Depending on the transport protocol, some of this information may be absent.

Git supports ssh, git, http, and https protocols (in addition, ftp, and ftps can be used for fetching, but this is inefficient and deprecated; do not use it).

The native transport (i.e. git:// URL) does no authentication and should be used with caution on unsecured networks.

The following syntaxes may be used with them:

How to use git clone

Check your version of git by running

SYNOPSIS

DESCRIPTION

After the clone, a plain git fetch without arguments will update all the remote-tracking branches, and a git pull without arguments will in addition merge the remote master branch into the current master branch, if any (this is untrue when «—single-branch» is given; see below).

This default configuration is achieved by creating references to the remote branch heads under refs/remotes/origin and by initializing remote.origin.url and remote.origin.fetch configuration variables.

OPTIONS

Operate quietly. Progress is not reported to the standard error stream.

Run verbosely. Does not affect the reporting of progress status to the standard error stream.

No checkout of HEAD is performed after the clone is complete.

When given, and the repository to clone from is accessed via ssh, this specifies a non-default path for the command run on the other end.

Specify the directory from which templates will be used; (See the «TEMPLATE DIRECTORY» section of git-init[1].)

Set a configuration variable in the newly-created repository; this takes effect immediately after the repository is initialized, but before the remote history is fetched or any files checked out. The key is in the same format as expected by git-config[1] (e.g., core.eol=true ). If multiple values are given for the same key, each value will be written to the config file. This makes it safe, for example, to add additional fetch refspecs to the origin remote.

Create a shallow clone with a history after the specified time.

Create a shallow clone with a history, excluding commits reachable from a specified remote branch or tag. This option can be specified multiple times.

After the clone is created, initialize and clone submodules within based on the provided pathspec. If no pathspec is provided, all submodules are initialized and cloned. This option can be given multiple times for pathspecs consisting of multiple entries. The resulting clone has submodule.active set to the provided pathspec, or «.» (meaning all submodules) if no pathspec is provided.

All submodules which are cloned will be shallow with a depth of 1.

Instead of placing the cloned repository where it is supposed to be, place the cloned repository at the specified directory, then make a filesystem-agnostic Git symbolic link to there. The result is Git repository can be separated from working tree.

The number of submodules fetched at the same time. Defaults to the submodule.fetchJobs option.

The (possibly remote) repository to clone from. See the GIT URLS section below for more information on specifying repositories.

The name of a new directory to clone into. The «humanish» part of the source repository is used if no directory is explicitly given ( repo for /path/to/repo.git and foo for host.xz:foo/.git ). Cloning into an existing directory is only allowed if the directory is empty.

GIT URLS

In general, URLs contain information about the transport protocol, the address of the remote server, and the path to the repository. Depending on the transport protocol, some of this information may be absent.

Git supports ssh, git, http, and https protocols (in addition, ftp, and ftps can be used for fetching, but this is inefficient and deprecated; do not use it).

The native transport (i.e. git:// URL) does no authentication and should be used with caution on unsecured networks.

The following syntaxes may be used with them:

Источники информации:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *