Trung BìnhGit iconGit

Signed commits với GPG/SSH là gì? Khi nào enterprise team cần enforce?

Signed commits đảm bảo commit thực sự từ người có private key tương ứng — chống giả mạo identity (bất kỳ ai cũng có thể set git config user.email thành email của bạn).

Setup GPG signing:

bash
gpg --gen-key
gpg --list-secret-keys --keyid-format=long
# Lấy key ID, ví dụ: 3AA5C34371567BD2
git config --global user.signingkey 3AA5C34371567BD2
git config --global commit.gpgsign true
# Upload public key lên GitHub Settings → SSH and GPG keys

SSH signing (mới hơn, dễ hơn GPG):

bash
git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/id_ed25519.pub
git config --global commit.gpgsign true

GitHub hiển thị badge Verified trên commit khi signature hợp lệ.

Khi nào enforce:
- Regulated industries (fintech, healthcare) — audit trail
- Open source projects — chống supply chain attack (ai đó push code giả tên maintainer)
- Khi GitHub Actions deploy từ commits — đảm bảo chỉ deploy signed commits

Lưu ý: GPG key rotation phức tạp — SSH signing dễ manage hơn cho enterprise.

Xem toàn bộ Git cùng filter theo level & chủ đề con.

Mở danh sách Git