git clone
Git clone (git 克隆..)
Description
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.
The git clone usage
The git clone usage
First of all, the git clone command is used to target an existing repository and clone or copy it in a new directory. A local copy stored on a server, that is accessible at example.comcan be obtained using the SSH username x_person , like this:
git clone ssh://[email protected]/path/to/team-project.git
cd team-project
# You must work on this project
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 <repo> into the folder called <directory> on the local machine.
git clone <repo> <directory>
Cloning a certain tag
Clone the repository at <repo> and clone only the ref for <tag>.
git clone --branch <tag> <repo>
Difference Between git init and git clone
Difference Between git init and git clone
The git init and git clone are usually confused with each other. Here it’s important to note that git clone is dependant on the git init and creates a copy of a repository that already exists. In other words, for generating a git clone, we need a repository created with git init. Only after that, we run a git clone to copy the data that is included in our repository mentioned above.
Configuration Options of Git Clone
Configuration Options of Git Clone (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 clone -branch new_feature git://remoterepository.git
Git URLs
Git URLs (Git网址)
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
Git can use the following protocols for data transfer: Git , Secure Shell (SSH) , HTTPS and Local. It should be noted that all these protocols require Git to be installed and working on the server except for HTTPS protocols.
git://host.xz[:port]/path/to/repo.git/