Git Cheat Sheet · Getting started
Clone a repository
git clone <url>
To get a project hosted on GitHub, GitLab or a Git server, run git clone <url>. Git downloads the whole history, creates the working copy on the default branch and saves the repository's address under the name "origin".
What it does
Downloads a remote repository with its whole history and links it to its "origin" remote.
A use case
You are joining a project hosted on GitHub or GitLab and you want a working copy on your machine.
On the command line
git clone https://github.com/<account>/<project>.git- Clones over HTTPS, into a folder named after the project.
git clone git@github.com:<account>/<project>.git- Clones over SSH, with your SSH key rather than a password or a token.
git clone <url> <folder>- Sets the name of the destination folder.
git clone -b <branch> <url>- Starts directly on a branch other than the default one.
git clone --depth 1 <url>- Shallow clone: only the last commit, much faster on a large repository.
git clone --recurse-submodules <url>- Also fetches the submodules.
In Merathon
- Repository menu → "Clone…".
- Paste the URL, or choose a repository from a connected account's list.
- Choose the parent folder and the folder name, then confirm.
Frequently asked questions
What is the difference between cloning over HTTPS and SSH?
Over HTTPS, you authenticate with a token; over SSH, with a key registered on the forge. The content you get is the same. In Merathon, an account connected with OAuth saves you from managing either by hand.
What is the difference between git clone and git pull?
git clone creates a new local copy of a repository. git pull updates a copy that already exists.
Why are some files only a few bytes after a clone?
They are Git LFS pointers: run git lfs pull to get their content.