edit trong interactive rebase dừng tại 1 commit cụ thể, cho phép bạn amend nó trước khi tiếp tục rebase.
Những gì edit làm được mà squash không:
1. Tách 1 commit thành nhiều commits:
git rebase -i HEAD~3
# Đánh dấu commit cần tách là: edit abc123
# Git dừng tại abc123
git reset HEAD~ # unstage commit, giữ files
git add src/auth/
git commit -m "feat(auth): add login logic"
git add src/tests/
git commit -m "test(auth): add login tests"
git rebase --continue**2.
Chèn commit mới vào giữa history:**
# Dừng tại commit cần chèn trước
# Tạo file mới, commit
git add new-file.ts
git commit -m "feat: add missing helper"
git rebase --continue**3.
Thay đổi nội dung file trong commit cũ (không chỉ message):**
# Dừng tại commit cần sửa
# Edit files
git add changed-file.ts
git commit --amend --no-edit
git rebase --continueCẩn thận: edit mode tạo ra commits mới với hash khác → mọi commits phía sau cũng có hash mới → cần force push.
edit in interactive rebase pauses at a specific commit, letting you amend it before continuing the rebase.
What edit can do that squash cannot:
1. Split one commit into multiple commits:
git rebase -i HEAD~3
# Mark the commit to split as: edit abc123
# Git pauses at abc123
git reset HEAD~ # unstage the commit, keep the files
git add src/auth/
git commit -m "feat(auth): add login logic"
git add src/tests/
git commit -m "test(auth): add login tests"
git rebase --continue**2.
Insert a new commit in the middle of history:**
# Pause at the commit you want to insert before
# Create new file, commit it
git add new-file.ts
git commit -m "feat: add missing helper"
git rebase --continue**3.
Change file content in an old commit (not just the message):**
# Pause at the commit to fix
# Edit files
git add changed-file.ts
git commit --amend --no-edit
git rebase --continueWarning: edit mode creates new commits with different hashes → all subsequent commits also get new hashes → force push required.