Git

Clone

You might say

Here's a project URL. How do I download the whole codebase to my computer so I can edit it?

Create a local copy of a remote repository and its historyClone downloads a repository, creates a working directory, and configures the original location as a remote. It is normally the first step when joining an existing project. Check the destination path and repository source before running it.
Remote repositoryFiles and commit history
Create a local copyclone→
New local repositoryReady to work on your computer
git clone <repository-url>

Clone creates a new local repository from a remote repository, including its files, branches, and commit history. After cloning once, use pull to bring later remote commits into that local repository.

Anatomy
https://github.com/maya-lee/my-first-page.git
An HTTPS URL works without setting up an SSH key first.
The Git hosting service, such as GitHub or Gitee
The repository owner; after a fork, this segment becomes your account name
The repository name, which also becomes the local folder name by default
Variants
git clone
git clone https://github.com/maya-lee/my-first-page.git
Download working files, repository metadata, and reachable commit history
clone + 名字
git clone <address> my-app
Want to change the name of the local folder
Download ZIP
Code ▾ → Download ZIP
When you only need working files and no Git history
Fork
Upper right of the webpage ⑂ Fork
When you need to create a remote copy under your own account
Typical use cases
Join a project
my-first-page <> Code ▾
HTTPSSSHGitHub CLI
https://github.com/maya-lee/my-first-page.git 📋 Copy URL
Set up a new computer
zsh — ~/projects
$ git clone https://github.com/maya-lee/my-first-page.git Cloning into 'my-first-page'... remote: Enumerating objects: 36, done. remote: Counting objects: 100% (36/36), done. Receiving objects: 100% (36/36), 12.4 KiB | 2.1 MiB/s, done. Created a local repository at ~/projects/my-first-page
Review an open-source repository
zsh — my-first-page
$ git log --oneline e7b2d48 Fix button alignment on mobile a3f9c21 Finish the home-page navigation b4c5d67 Home page basic version 0f1e2d3 Initialize project After cloning, use git log to view the commit history
Create a clean working copy
maya-lee / my-first-page ⑂ Fork 12
⑂
xiaoli / my-first-page
forked from maya-lee/my-first-page
A fork is a separate repository under your account. Clone the fork locally before working on it and pushing commits to it.
Further reading