0Pricing
Git Advanced: Monorepo, Submodules & Workflows · บทเรียน

การรักษาความปลอดภัย Git ใน DevOps: ข้อมูลลับ การลงลายมือชื่อ และฮุก

เรียนรู้การเก็บข้อมูลลับไม่ให้ปะปนอยู่ใน Git การยืนยันผู้เขียนด้วยคอมมิตที่ลงลายเซ็น และการบังคับใช้นโยบายอัตโนมัติด้วยฮุกใน DevOps และกระบวนการอัตโนมัติ

การรักษาความปลอดภัย Git ใน DevOps: ข้อมูลลับ การลงลายมือชื่อ และฮุก เป็นบทเรียน Git Advanced: Monorepo, Submodules & Workflows ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Git Advanced: Monorepo, Submodules & Workflows และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Git Advanced: Monorepo, Submodules & Workflows มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Git Is a Security Surface

In DevOps, Git drives deployments. That makes the repository a security surface: a leaked secret or a forged commit can compromise production. Securing Git is part of securing the pipeline.

Keep Secrets Out of History

Never commit API keys, tokens, or passwords. Once in history, a secret is effectively public forever, even after deletion, because the old commit still contains it.

Use a .gitignore and environment variables instead.

.env
*.pem
secrets/
config/credentials.json

Scanning for Leaked Secrets

Automated scanners catch secrets before they merge. Wire one into CI so a leaked token fails the build.

gitleaks detect --source . --verbose

If a Secret Leaks

If a secret reaches the remote, two steps are mandatory:

  • Rotate the credential immediately — assume it is compromised
  • Purge it from history with a tool like git filter-repo

Rotation matters more than purging.

git filter-repo --path config/credentials.json --invert-paths

Signing Commits

Signed commits prove who authored them. In automated environments this prevents impersonation and lets pipelines trust commit authorship.

git config commit.gpgsign true
git commit -S -m 'Deploy config update'

Verifying Signatures

CI can require that every commit on a protected branch is signed and verified, rejecting unsigned or unknown-key commits before they deploy.

git log --show-signature -1
git verify-commit HEAD

Client-Side Hooks

Hooks run scripts at Git lifecycle events. A pre-commit hook can block secrets or run linters before a commit is ever created.

#!/bin/sh
# .git/hooks/pre-commit
gitleaks protect --staged || exit 1

Server-Side Hooks

Client hooks can be bypassed. Server-side hooks (pre-receive) enforce policy centrally, rejecting non-compliant pushes for everyone, no matter their local setup.

#!/bin/sh
# pre-receive: reject force pushes to main
while read old new ref; do
  if [ "$ref" = 'refs/heads/main' ]; then
    echo 'Direct pushes to main are blocked'; exit 1
  fi
done

Branch Protection as Policy

Platform branch-protection rules complement hooks: require reviews, passing CI, and signed commits before merge. Policy enforced at the platform cannot be bypassed locally.

Least Privilege for Automation

Deploy bots should use scoped, short-lived tokens, not personal credentials. Grant only the access a job needs, and rotate tokens regularly to limit blast radius.

Auditing the Audit Trail

Git history and platform logs form an audit trail. Protect them: disallow history rewrites on shared branches and review who has admin rights, so the record of what shipped stays trustworthy.

Quick Check

Test your understanding of Git security in DevOps.

Recap

You learned to secure Git in DevOps: keep secrets out of history, scan automatically, rotate then purge on leaks, use signed commits, enforce policy with client and server-side hooks and branch protection, and apply least privilege to automation tokens.

คำถามที่พบบ่อย

บทเรียน “การรักษาความปลอดภัย Git ใน DevOps: ข้อมูลลับ การลงลายมือชื่อ และฮุก” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “การรักษาความปลอดภัย Git ใน DevOps: ข้อมูลลับ การลงลายมือชื่อ และฮุก” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Git Advanced: Monorepo, Submodules & Workflows ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Git Advanced: Monorepo, Submodules & Workflows มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “การรักษาความปลอดภัย Git ใน DevOps: ข้อมูลลับ การลงลายมือชื่อ และฮุก”

เรียนรู้การเก็บข้อมูลลับไม่ให้ปะปนอยู่ใน Git การยืนยันผู้เขียนด้วยคอมมิตที่ลงลายเซ็น และการบังคับใช้นโยบายอัตโนมัติด้วยฮุกใน DevOps และกระบวนการอัตโนมัติ คุณปฏิบัติ Git Advanced: Monorepo, Submodules & Workflows ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Git Advanced: Monorepo, Submodules & Workflows หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Git Advanced: Monorepo, Submodules & Workflows บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน

บทเรียน “การรักษาความปลอดภัย Git ใน DevOps: ข้อมูลลับ การลงลายมือชื่อ และฮุก” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Git Advanced: Monorepo, Submodules & Workflows นี้ได้ไหม

ได้ บทเรียน Git Advanced: Monorepo, Submodules & Workflows ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. หลักการและการนำ GitOps ไปใช้
  2. การทำงาน Git ให้เป็นอัตโนมัติด้วยสคริปต์
  3. การผสานรวม Git กับ CI/CD
  4. การรักษาความปลอดภัย Git ใน DevOps: ข้อมูลลับ การลงลายมือชื่อ และฮุก
← กลับไปที่ Git Advanced: Monorepo, Submodules & Workflows