Vấn đề: bạn có local commits chưa push. Teammate đã push lên remote. git pull = git fetch + git merge → tạo merge commit "Merge branch 'main' of github.com/..." không mang thông tin gì, git log --graph đầy những vòng merge vô nghĩa.
Fix: dùng rebase khi pull:
bash
git pull --rebase origin main # = fetch + rebase → history linear
git config --global pull.rebase true # set làm defaultNếu gặp conflict giữa chừng: resolve file → git add → git rebase --continue; hoặc git rebase --abort để về trạng thái trước pull.
Khi nào dùng git pull (merge) thay vì rebase:
- Branch đã có merge commits quan trọng (merge commit là intentional)
- Long-lived feature branch muốn preserve merge history
Tip: git pull --rebase --autostash tự động stash local changes trước khi rebase, unstash sau.