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.
When to use it
- Start work on an existing repository
- Download a full project history
- Create a fresh local working copy
- Set up the default remote automatically
When NOT to use it
- Clone into a directory that already contains important files
- Download code from an untrusted source and run it immediately
- Clone again every time the remote changes
- Assume private dependencies and environment settings are included
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 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
Set up a new computer
$ 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
$ 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
Further reading