Ask Steves · Daily notes · VPS, 20% off · AI Profit Lab · SEO · Money Hub

15 November 2026 · One command a day

How do I copy a git repository onto my Linux server?

git clone downloads a full copy of a git repository into a new folder on your server. You get every file, the full history and a link back to where it came from. You reach for it the first time you put an app or site onto a fresh VPS.

I learn my automation tips in the AI Profit Boardroom. Have a look here. Affiliate link.

The command

git clone https://example.com/user/appname.git /home/user/apps/appname

git clone is the command itself. The first argument is the repository URL. It can be HTTPS, as here, or SSH in the form git@example.com:user/appname.git. The second argument is optional and sets the folder to clone into. If you leave it out, git makes a folder named after the repository, here appname, in the directory you are in. The folder must not exist yet, or it must be empty. If git is missing, install it with sudo apt install git.

What you will see

Cloning into '/home/user/apps/appname'...
remote: Enumerating objects: 1243, done.
remote: Counting objects: 100% (1243/1243), done.
remote: Compressing objects: 100% (612/612), done.
remote: Total 1243 (delta 580), reused 1100 (delta 501), pack-reused 0
Receiving objects: 100% (1243/1243), 2.31 MiB | 8.40 MiB/s, done.
Resolving deltas: 100% (580/580), done.

The first line shows where the copy is going. The remote: lines come from the server you are cloning from while it packs the repository. Receiving objects is the download, with its size and speed. Resolving deltas is git rebuilding the files on your side. When the prompt comes back with no error, the folder is ready. Run cd into it and git status to check you are on the expected branch.

When to use it

Watch out for

Do not run sudo git clone into a folder your app or web server will use. Every file then belongs to root. Later git pull runs as your normal user fail, and the app cannot write to its own folders. Clone as the user that will own the code. If you have already cloned as root, see how to fix file ownership after running something as root. To check where the new clone will pull from and push to, see how to see where a git repository pushes to.

Questions people ask

How do I clone only the latest version without the history?

Add --depth 1, as in git clone --depth 1 https://example.com/user/appname.git. The download is much smaller, which helps on big repositories.

How do I clone a particular branch?

Use --branch followed by the branch name, for example git clone --branch staging https://example.com/user/appname.git. Git checks out that branch instead of the default one.

Choosing where code lives, which user owns it and how it gets there is the kind of thing you can only do on a server you control. You can get the same VPS with 20% off at https://asksteves.co.uk/vps. Affiliate link.

Want more automation tips? The AI Profit Boardroom on Skool is where I get mine. Have a look here. Affiliate link.

Everything on this blog runs on one Hostinger KVM 8. This link takes 20% off the same box.

GET A VPS, 20% OFF →

Affiliate link.

Related server notes: How do I see exactly which lines changed in my files with git diff? · How do I copy a file to or from a server with scp? · How do I fix file ownership on Linux after running something as root? · All daily notes