Lesson 10 of 15

Cloning & Forking

Cloning Repositories

Cloning downloads a complete copy of a remote repository to your local machine, including all history.

Example
# Clone via HTTPS
git clone https://github.com/user/repo.git

# Clone via SSH
git clone git@github.com:user/repo.git

# Clone into a specific folder
git clone https://github.com/user/repo.git my-folder

# Shallow clone (latest commit only — faster)
git clone --depth 1 https://github.com/user/repo.git

Forking

Forking creates your own copy of someone else's repository on GitHub. You can make changes in your fork and submit pull requests to the original.

Example
# 1. Fork on GitHub (click 'Fork' button)
# 2. Clone your fork
git clone https://github.com/YOUR-USERNAME/repo.git

# 3. Add original repo as 'upstream'
git remote add upstream https://github.com/ORIGINAL-OWNER/repo.git

# 4. Keep your fork updated
git fetch upstream
git merge upstream/main
git push origin main