Skip to Content

Clone Repository

Clone là gì?

Clone là tải toàn bộ repository từ GitHub về máy tính của bạn, bao gồm:

  • Tất cả source code
  • Toàn bộ lịch sử commit
  • Tất cả các branch

Cách lấy URL để Clone

  1. Vào repository trên GitHub
  2. Nhấn nút Code (màu xanh)
  3. Chọn tab HTTPS hoặc SSH
  4. Copy URL

HTTPS vs SSH

HTTPSSSH
Dễ thiết lậpCần cấu hình SSH key
Nhập password mỗi lần pushKhông cần nhập password
https://github.com/user/repo.git[email protected]:user/repo.git

💡 Khuyến nghị: Bắt đầu với HTTPS, chuyển sang SSH khi quen.

Clone bằng Command Line

Bước 1: Mở Terminal/Command Prompt

  • macOS: Terminal
  • Windows: Git Bash hoặc Command Prompt
  • Linux: Terminal

Bước 2: Di chuyển đến thư mục muốn lưu

cd ~/Documents/Projects

Bước 3: Clone repository

git clone https://github.com/username/repository-name.git

Bước 4: Vào thư mục dự án

cd repository-name

Clone trong VS Code

  1. Mở VS Code
  2. Nhấn Cmd+Shift+P (Mac) hoặc Ctrl+Shift+P (Windows)
  3. Git: Clone
  4. Paste URL repository
  5. Chọn thư mục lưu

Clone trong Android Studio / IntelliJ

  1. FileNewProject from Version Control
  2. Paste URL repository
  3. Chọn thư mục lưu
  4. Nhấn Clone

Xác minh Clone thành công

# Kiểm tra Git status git status # Xem lịch sử commit git log --oneline

Tiếp theo

Sau khi clone, hãy học cách Push code lên GitHub!

Last updated on