Skip to main content

Git Basics

Cấu hình

git config --global user.name "Your Name"
git config --global user.email "your@email.com"

Workflow cơ bản

git init # Khởi tạo repo
git add . # Stage tất cả
git commit -m "message" # Commit
git push origin main # Push lên remote
git pull # Pull từ remote

Branching

git branch feature-x # Tạo branch mới
git checkout feature-x # Chuyển branch
git checkout -b feature-x # Tạo + chuyển
git merge feature-x # Merge vào branch hiện tại

Những lệnh hữu ích

git status # Xem trạng thái
git log --oneline # Xem lịch sử commit
git diff # Xem thay đổi
git stash # Tạm cất thay đổi
git reset HEAD~1 # Undo commit gần nhất