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
- Vào repository trên GitHub
- Nhấn nút Code (màu xanh)
- Chọn tab HTTPS hoặc SSH
- Copy URL
HTTPS vs SSH
| HTTPS | SSH |
|---|---|
| Dễ thiết lập | Cần cấu hình SSH key |
| Nhập password mỗi lần push | Khô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/ProjectsBước 3: Clone repository
git clone https://github.com/username/repository-name.gitBước 4: Vào thư mục dự án
cd repository-nameClone trong VS Code
- Mở VS Code
- Nhấn
Cmd+Shift+P(Mac) hoặcCtrl+Shift+P(Windows) - Gõ Git: Clone
- Paste URL repository
- Chọn thư mục lưu
Clone trong Android Studio / IntelliJ
- File → New → Project from Version Control
- Paste URL repository
- Chọn thư mục lưu
- 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 --onelineTiếp theo
Sau khi clone, hãy học cách Push code lên GitHub!
Last updated on