Git clone ( git clone
) Command
git clone is for taking repository into your local system into a new empty directory or it will create a new directory with same name as report git repository name
Git clone creates remote-tracking branches for each branch in the cloned repository, visibale using the comamnd
git branch -r
and also checkout the default branch of the reporitory genreally master branch, it also create a references to the remote branch heads under refs/remotes/origin and by initializing remote.origin.url and remote.origin.fetch configuration variables, this configuration is easily available by the command git remote -v
Examples
- Clone with HTTPS:
git clone https://github.com/username/reporistory_name.git
- Clone with SSH:
git@github.com:username/reporistory_name.git
Which remote URL should we use for clone?
There are several ways to clone repositories available on GitHub.
The https://
clone URLs are available on all repositories, public and private. These URLs work everywhere--even if you are behind a firewall or proxy. In certain cases, if you'd rather use SSH, you might be able to use SSH over the HTTPS port. SSH URLs provide access to a Git repository via SSH, a secure protocol.
Summary
git clone
is used to create a clone / copy of the required repository.