Junior #staging#add#commit#basics
Working directory, staging area và repository trong Git
⚡ Trả lời nhanh
File đi qua ba vùng: working directory (đang sửa), staging area/index (git add, chọn thay đổi sẽ vào commit tiếp theo) và repository (git commit lưu snapshot). Staging cho phép commit chỉ một phần thay đổi.
git init # hoặc: git clone <url>
git status # xem file ở vùng nào
git add src/app.js # đưa vào staging
git add -p # chọn từng hunk
git commit -m "feat: add login"
git diff # working vs staging
git diff --staged # staging vs commit gần nhất
git restore --staged app.js # bỏ khỏi staging, giữ nguyên thay đổi
working directory --git add--> staging area --git commit--> repository