How to clone a repository?

git clone repo_url

To clone a remote repository use git clone repo_url. You will need to know the remote address of the repository. In this example we clone a repository from GitHub.

There are multiple options to clone a repository. You can clone over HTTPS, which doesn't require any setup. You can also clone over SSH, which requires you to upload your public SSH key to your GitHub account.

Layer 1
Terminal Example
# Over SSH
git clone git@github.com:github/gitignore.git
Cloning into 'gitignore'...
remote: Enumerating objects: 9118, done.
remote: Counting objects: 100% (98/98), done.
remote: Compressing objects: 100% (62/62), done.
remote: Total 9118 (delta 50), reused 80 (delta 36), pack-reused 9020
Receiving objects: 100% (9118/9118), 2.12 MiB | 318.00 KiB/s, done.
Resolving deltas: 100% (4935/4935), done.

# Over HTTPS
git clone https://github.com/github/gitignore.git
Cloning into 'gitignore'...
remote: Enumerating objects: 9118, done.
remote: Counting objects: 100% (98/98), done.
remote: Compressing objects: 100% (62/62), done.
remote: Total 9118 (delta 50), reused 80 (delta 36), pack-reused 9020
Receiving objects: 100% (9118/9118), 2.12 MiB | 355.00 KiB/s, done.
Resolving deltas: 100% (4935/4935), done.

See git clone to learn more about it.

Last modified on November 30, 2021.

You might also like