Skip to content

PlusMagi's Blog By Pitt Phunsanit

Plus emotional magic to the knowledge of logic.

  • About’s Pitt
Close Button
PlusMagi's Blog By Pitt Phunsanit Uncategorized Git: Commit Prefix Message

Git: Commit Prefix Message

2009-08-092009-08-09| phunsanitphunsanit| 0 Comment | 07:00
Categories:
  • Uncategorized

การใช้ Git Commit Prefix เป็นแนวทางปฏิบัติที่ช่วยให้การทำงานร่วมกันในทีมเป็นระบบมากขึ้น ทำให้ประวัติการแก้ไข (Git History) อ่านง่าย และช่วยให้ระบบ Automate ต่าง ๆ เช่น การสร้าง Changelog อัตโนมัติทำงานได้อย่างแม่นยำ

บทความนี้จะสรุปมาตรฐานที่นิยมใช้ที่สุดคือ Conventional Commits ครับ


ทำไมต้องใช้ Git Prefix ?

  1. Readability: เข้าใจได้ทันทีว่าการเปลี่ยนแปลงนั้นเกี่ยวกับอะไร
  2. Efficiency: ค้นหาประวัติการแก้ไขได้รวดเร็วด้วยคำสั่ง
    git log --grep
  3. Automation: สามารถใช้เครื่องมือช่วยรวบรวม Version และ Release Notes ได้อัตโนมัติ

รูปแบบมาตรฐาน

รูปแบบที่นิยมที่สุดประกอบด้วย 3 ส่วนหลัก
type: description

  • Type: ประเภทของการเปลี่ยนแปลง
  • Scope: ส่วนของโปรเจกต์ที่ได้รับผลกระทบ เช่น , ,
  • Description: คำอธิบายสั้น ๆ ว่าทำอะไร (บังคับ)

ประเภทของ Prefix ที่พบบ่อย

Prefixการใช้งาน
featการเพิ่ม Feature ใหม่ให้กับระบบ
fixการแก้ไข Bug ต่าง ๆ
docsการแก้ไข Documentation
styleการปรับแก้รูปแบบโค้ด โดยไม่กระทบ Logic
refactorการแก้ไขโค้ดเพื่อให้อ่านง่ายหรือประสิทธิภาพดีขึ้น โดยไม่มีการแก้บั๊กหรือเพิ่มฟีเจอร์
perfการปรับปรุงประสิทธิภาพ ของโค้ด
testการเพิ่มหรือแก้ไข Test Cases
buildการเปลี่ยนแปลงที่กระทบระบบ Build หรือ External Dependencies
ciการแก้ไขไฟล์ตั้งค่า CI Configuration
choreงานจิปาถะอื่น ๆ เช่น การอัปเดตไฟล์ .gitignore
revertการยกเลิก Commit ก่อนหน้า
securitySecurity

ตัวอย่างการใช้งานจริง

  • เพิ่มฟีเจอร์ใหม่: feat: add google oauth2 login
  • แก้ไขบั๊ก: fix: resolve memory leak in user controller
  • อัปเดตเอกสาร: docs: update installation steps in README
  • ปรับปรุงประสิทธิภาพ: perf: optimize query for dashboard statistics
  • งานทั่วไป: chore: update dependencies

ข้อแนะนำเพิ่มเติม

  1. ใช้คำกริยาที่เป็นปัจจุบัน : เช่นใช้ add แทน added หรือ adds ให้มองว่ามันคือคำสั่งว่า “ถ้า apply commit นี้ มันจะทำอะไร”
  2. เริ่มด้วยอักษรตัวเล็ก: โดยทั่วไปนิยมใช้ตัวเล็กทั้งหมดสำหรับ Prefix
  3. กระชับแต่ได้ใจความ: ส่วน Description ไม่ควรยาวเกิน 50-72 ตัวอักษร
  4. แยกการแก้ไข: หากมีการแก้ไขหลายอย่างในคราวเดียว ควรแยกเป็นหลาย Commit เพื่อให้ใส่ Prefix ได้ถูกต้องแม่นยำ

อ่านเพิ่มเติม

  • GIT: Cherry-pick: เก็บเฉพาะลูก
  • GIT: update personal access tokens in all sub folder
  • GIT: ละเว้นไฟล์ temp ของพวก office
ป้ายกำกับ:Add, APIs, Automation, Best, Bug, Build, Commit, Composer, Configuration, Database, Dependencies, Documentation, Feature, Fix, GIT, GIT, Log, Logic, Login, Memory, Performance, Practices, Prefix, Query, Readability, Release, Revert, Scope, Security, Semicolon, Structure, Test, Types, UI, Update, User, Version, ฟีเจอร์, มาตรฐาน, อัปเดต, เอกสาร, ไฟล์

Leave a Reply ยกเลิกการตอบ

คุณต้องเข้าสู่ระบบ เพื่อจะพิมพ์ความเห็น

แนะแนวเรื่อง

PREVIOUS Previous post: nginx: W: http://nginx.org/packages/ubuntu/dists/focal/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8)for details.
NEXT Next post: MySQL: แทรก id ที่ว่างอยู่

Projects

  • Statement Columns Mapping Helper
  • PlusMagi Site Search
  • jQuery Plus Repeater

Recent Posts

  • Homebrew: แชร์กันหลาย User (Multi-User Setup)
  • TabulatorPlus: Universal Style
  • Sci-Fi: นิยายไซไฟ
  • TabulatorPlus: ในแต่ละ Framework
  • Markdown: มาเริ่มเขียนกันเถอะ

Archives

Categories

  • AI (25)
  • API (12)
    • REST (5)
    • Swagger (6)
  • Businesses (19)
  • Database (158)
    • DBeaver (3)
    • MariaDB (29)
    • MySql (67)
    • Oracle Database (6)
      • 10g (3)
    • RDBMS (2)
    • SQL Server (85)
      • SSMS (8)
      • T-SQL (26)
    • SQLite (1)
  • Design (48)
    • UX/UI (14)
  • Docker (1)
  • GIT (5)
  • Histories (14)
  • Java (15)
    • Spring Boot (14)
  • JavaScript (85)
    • Angular (3)
    • jQuery (61)
    • Tabulator (18)
    • Vue.js (5)
  • Life (112)
    • Books (47)
    • Cartoon (5)
    • Movies (9)
    • Sci-Fi (18)
    • Tips and Tricks (26)
    • พุทธ (6)
  • Linux (5)
  • macOS (13)
    • OrbStack (11)
  • Network (24)
    • Apache HTTP Server (16)
    • IOT (1)
    • Stalwart (6)
  • Nginx (1)
  • Operating Systems (89)
    • Unix-like (87)
      • Android (16)
        • F-Droid (5)
      • Homebrew (19)
      • iPhone (8)
      • Oh My ZSH (4)
      • Shell Script (34)
      • SSH (11)
  • PostgreSQL (1)
  • Programming (415)
    • .NET (19)
      • .NET Core EF (6)
      • C# (17)
    • PowerBuilder (10)
    • Python (5)
    • Rust (1)
    • System Analyst (SA) (24)
    • Testing (19)
      • Automated Testing (10)
        • Playwright (6)
    • UML (7)
  • Programs (91)
    • Excel (10)
  • SecDevOps (28)
    • CI/CD (5)
  • Security (7)
  • Uncategorized (3)
  • Web (216)
    • Backend (196)
      • Golang (1)
      • Node.js (2)
      • PHP (194)
        • Laravel (16)
        • Yii (5)
    • Frontend (19)
      • CSS (18)
        • Tailwind CSS (5)
  • Windows (28)
    • PowerShell (24)
  • WordPress (2)
  • กฎหมาย (5)

Sirat WordPress Theme By VWThemes

Scroll Up
Go to mobile version