Clone a Repository
git clone https://github.com/user/project.gitGit creates a folder named project (the address without .git), downloads every commit into it, and checks out the default branch. Go into the folder before you run other Git commands:
cd project
git log --oneline -3
git remote -vIf git is not found, install it first; see how to install Git on Linux.
HTTPS or SSH Address
Most hosting services show two kinds of address on the repository page.
| HTTPS | SSH | |
|---|---|---|
| Starts with | https:// | the user git |
| Login | Access token | SSH key |
| Public repository | No login needed | Key still needed |
| Good for | Quick reads | Servers and pushing |
The SSH address shown on the page starts with the user name git, then the host name, a colon, and the repository path. Git also accepts the same address in URL form:
git clone ssh://git@your_git_host/user/project.gitReplace your_ with the host name of your service, or with a host alias from your SSH config file. GitHub and many other services no longer accept your account password for Git over HTTPS; they ask for an access token instead.
Choose the Folder
Add a folder name after the address:
git clone https://github.com/user/project.git site
git clone https://github.com/user/project.git .The first line clones into site. The dot clones into the current folder, which must be empty.
Clone a Specific Branch
git clone -b develop https://github.com/user/project.git-b checks out develop instead of the default branch. The other branches are still downloaded. -b also accepts a tag, which leaves you on that release without a branch.
Shallow Clone with --depth
git clone --depth 1 https://github.com/user/project.gitOnly the latest commit is downloaded, which is faster for a large repository when you only need the files. A shallow clone fetches a single branch unless you add --no-single-branch. To get the full history later, run git fetch --unshallow.
Include Submodules
Some projects pull other repositories in as submodules. Clone them in the same step:
git clone --recurse-submodules https://github.com/user/project.gitIf you already cloned without them, the submodule folders are empty. Fill them with:
git submodule update --init --recursiveClone onto a Server with a Deploy Key
For a private repository on a server, a read-only deploy key is safer than your account password or a personal token. The key setup is in how to use SSH keys with GitHub. Then clone as the user that runs the site, not as root. Create the folder with sudo, then run the last two lines as that user (here deploy):
sudo mkdir -p /var/www/example.com
sudo chown deploy:deploy /var/www/example.com
cd /var/www/example.com
git clone ssh://git@your_git_host/user/project.git .Avoid storing an HTTPS token with credential.helper store on a shared server: it saves the token unencrypted in ~/.git-credentials, protected only by file permissions.
Common Errors
- Permission denied (publickey): the server's key is missing or not added to the hosting service. See how to fix permission denied (publickey).
- Repository not found: a typo in the address, or your account or key has no access to a private repository.
- Destination path already exists: the target folder exists and is not empty. Pick another name or clean the folder.
- Host key verification failed: SSH does not know or does not trust the host key of the Git service yet. See how to fix host key verification failed.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations