Skip to content

Git Commands 🔀

ROLE: HPN (Visual Concepts) & Engineer HPN (Workflow Best Practices).
AUDIENCE: Professional Engineers. Enterprise-standard Git mastery.

Hướng dẫn Git toàn diện từ cơ bản đến nâng cao, tuân thủ chuẩn quốc tế và thực tiễn doanh nghiệp.


📚 Nội dung

🟢 Cơ bản (Basic)

Nền tảng Git cho mọi lập trình viên.

  • Khởi tạo & Clone: git init vs git clone
  • Add & Commit: Staging Area, Atomic Commits, Conventional Commits
  • Push & Pull: Đồng bộ với Remote, git pull --rebase
  • Status & Log: Kiểm tra trạng thái, Pretty Log alias

🟡 Branching

Phân nhánh và quản lý workflow team.

  • Tạo & Chuyển branch: git switch, Naming Convention (feature/, bugfix/)
  • Merge vs Rebase: The Great Debate, HPN's Law
  • Giải quyết Conflict: Fearless Resolution, VS Code tools

🔴 Advanced

Kỹ năng cứu hộ và disaster recovery.

  • Cherry-pick: Hotfix cụ thể không merge toàn bộ
  • Stash: Context switching cho lập trình viên bận rộn
  • Reset & Revert: Undo an toàn vs nguy hiểm
  • Reflog: The Life Saver - Git never deletes anything

🚀 Quick Reference

bash
# Clone một repository
git clone https://github.com/user/repo.git

# Tạo branch mới (Modern)
git switch -c feature/login-page

# Commit theo chuẩn Conventional Commits
git add .
git commit -m "feat: add user authentication"

# Pull với rebase (Clean history)
git pull --rebase origin main

# Push lên remote
git push origin feature/login-page

💡 Triết lý Git tại PENALGO

  1. Atomic Commits: Một commit chỉ làm một việc.
  2. Conventional Commits: Dùng feat:, fix:, docs: để máy đọc được.
  3. Linear History: Ưu tiên rebase trên local, merge trên shared branch.
  4. Fearless Workflow: Conflict không đáng sợ. Reflog là lưới an toàn.

HPN'S GOLDEN RULE

"Code không sợ lỗi. Chỉ sợ không biết sửa."