{"id":1166,"date":"2023-10-17T16:17:08","date_gmt":"2023-10-17T16:17:08","guid":{"rendered":"https:\/\/www.devopssupport.in\/blog\/?p=1166"},"modified":"2023-10-26T16:23:21","modified_gmt":"2023-10-26T16:23:21","slug":"how-to-write-git-commit-messages","status":"publish","type":"post","link":"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/","title":{"rendered":"How to write Git Commit Messages"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/10\/image-22-1024x576.png\" alt=\"\" class=\"wp-image-1167\" srcset=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/10\/image-22-1024x576.png 1024w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/10\/image-22-300x169.png 300w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/10\/image-22-768x432.png 768w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/10\/image-22-1536x864.png 1536w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/10\/image-22-850x478.png 850w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/10\/image-22.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>When developers first step into the world of Git, they often encounter a certain discomfort, especially when it comes to crafting meaningful commit messages. The Git commit message, which encapsulates the changes made and why they were made, is a crucial part of version control. Developing good committing habits early in your career is essential. In this guide, we&#8217;ll explore how to improve your Git commit messages and why it matters.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Importance of Quality Commit Messages<\/h3>\n\n\n\n<p>Imagine this scenario: you open a repository, run <code>git log<\/code>, and find a list of cryptic commit messages like &#8220;Fix style&#8221; or &#8220;Update code.&#8221; Months later, you revisit the project and have no idea what these messages mean. Sound familiar? Well, this is a common issue with poorly written commit messages. Quality commit messages provide essential context and save you and your teammates time when troubleshooting or understanding past changes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Anatomy of a Commit Message<\/h3>\n\n\n\n<p>A Git commit message has two main parts: the subject line and the body.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Subject Line:<\/strong> This should be concise, not exceeding 50 characters. It should start with a capital letter and use the imperative mood (e.g., &#8220;Add,&#8221; &#8220;Fix,&#8221; &#8220;Update&#8221;). The subject line provides a high-level overview of the change.<\/li>\n\n\n\n<li><strong>Body:<\/strong> The body of the message is where you can explain in more detail. It should be wrapped at 72 characters and answer the questions of &#8220;why&#8221; and &#8220;what.&#8221;<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Steps to Writing Better Commit Messages<\/h3>\n\n\n\n<p>Let&#8217;s dive into practical steps to improve your commit messages:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1. Capitalization and Punctuation<\/h4>\n\n\n\n<p>Always start the subject line with a capital letter and don&#8217;t end it with punctuation. Conventional Commits, a popular convention, encourages using all lowercase.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2. Mood Matters<\/h4>\n\n\n\n<p>Use the imperative mood in the subject line. This creates a tone of giving an order or request. For example, &#8220;Fix the dark mode toggle state&#8221; is more appropriate than &#8220;Fixed the dark mode toggle state.&#8221;<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">3. Specify the Type of Commit<\/h4>\n\n\n\n<p>It&#8217;s beneficial to categorize your commits. Use a consistent set of words to describe your changes. For example, &#8220;Bugfix,&#8221; &#8220;Update,&#8221; &#8220;Refactor,&#8221; or &#8220;Bump.&#8221; This helps in classifying and searching for specific types of changes.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">4. Watch the Length<\/h4>\n\n\n\n<p>Keep the subject line short, ideally under 50 characters, and restrict the body to 72 characters per line. This ensures messages are concise and readable.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">5. Content Clarity<\/h4>\n\n\n\n<p>Be direct and avoid filler words and phrases. Think like a journalist, aiming to answer the &#8220;what&#8221; and &#8220;why&#8221; questions. Pretend that the reader has no prior knowledge of the change and needs a clear explanation.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Conventional Commits<\/h3>\n\n\n\n<p>Conventional Commits is a widely adopted format that provides structured commit messages. It uses the format: <code>&lt;type&gt;[optional scope]: &lt;description&gt;<\/code>. The <code>type<\/code> can include values like &#8220;feat&#8221; (new feature), &#8220;fix&#8221; (bug fix), &#8220;chore&#8221; (maintenance), and more. The optional scope specifies the part of the codebase affected, and the description provides a concise summary.<\/p>\n\n\n\n<p>This convention enhances consistency in commit messages and can be paired with tools like Commitizen to enforce standards.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Commit Message Comparisons<\/h3>\n\n\n\n<p>Let&#8217;s compare some examples to see the difference quality commit messages make:<\/p>\n\n\n\n<p><strong>Good:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>feat: Improve performance with lazy load implementation for images<\/code><\/li>\n\n\n\n<li><code>chore: Update npm dependency to the latest version<\/code><\/li>\n\n\n\n<li><code>Fix bug preventing users from submitting the subscribe form<\/code><\/li>\n\n\n\n<li><code>Update incorrect client phone number within the footer body per client request<\/code><\/li>\n<\/ul>\n\n\n\n<p><strong>Bad:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>Fixed bug on the landing page<\/code><\/li>\n\n\n\n<li><code>Changed style<\/code><\/li>\n\n\n\n<li><code>Oops<\/code><\/li>\n\n\n\n<li><code>I think I fixed it this time?<\/code><\/li>\n\n\n\n<li>Empty commit messages<\/li>\n<\/ul>\n\n\n\n<p>By following these guidelines, your commit messages can become valuable documentation, saving you and your team time and frustration. Whether you&#8217;re working solo or in a collaborative development environment, investing a little extra effort in crafting clear and meaningful commit messages pays off in the long run.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When developers first step into the world of Git, they often encounter a certain discomfort, especially when it comes to crafting meaningful commit messages. The Git commit&#8230; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[469,467,466,468],"class_list":["post-1166","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-commit-message-comparisons","tag-git-commit-messages","tag-how-to-write-git-commit-messages","tag-importance-of-quality-commit-messages"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to write Git Commit Messages - DevOps Support<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to write Git Commit Messages - DevOps Support\" \/>\n<meta property=\"og:description\" content=\"When developers first step into the world of Git, they often encounter a certain discomfort, especially when it comes to crafting meaningful commit messages. The Git commit...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/\" \/>\n<meta property=\"og:site_name\" content=\"DevOps Support\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-17T16:17:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-26T16:23:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/10\/image-22-1024x576.png\" \/>\n<meta name=\"author\" content=\"Avinash kumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Avinash kumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/\"},\"author\":{\"name\":\"Avinash kumar\",\"@id\":\"https:\/\/www.devopssupport.in\/blog\/#\/schema\/person\/ee29c62455ded10b2424fb9ca585e347\"},\"headline\":\"How to write Git Commit Messages\",\"datePublished\":\"2023-10-17T16:17:08+00:00\",\"dateModified\":\"2023-10-26T16:23:21+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/\"},\"wordCount\":560,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/10\/image-22-1024x576.png\",\"keywords\":[\"Commit Message Comparisons\",\"Git Commit Messages\",\"How to write Git Commit Messages\",\"Importance of Quality Commit Messages\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/\",\"url\":\"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/\",\"name\":\"How to write Git Commit Messages - DevOps Support\",\"isPartOf\":{\"@id\":\"https:\/\/www.devopssupport.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/10\/image-22-1024x576.png\",\"datePublished\":\"2023-10-17T16:17:08+00:00\",\"dateModified\":\"2023-10-26T16:23:21+00:00\",\"author\":{\"@id\":\"https:\/\/www.devopssupport.in\/blog\/#\/schema\/person\/ee29c62455ded10b2424fb9ca585e347\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/#primaryimage\",\"url\":\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/10\/image-22.png\",\"contentUrl\":\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/10\/image-22.png\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.devopssupport.in\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to write Git Commit Messages\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.devopssupport.in\/blog\/#website\",\"url\":\"https:\/\/www.devopssupport.in\/blog\/\",\"name\":\"DevOps Support\",\"description\":\"DevOps Support | DevSecOps Support | SRE Support | MLOps SRE Support\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.devopssupport.in\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.devopssupport.in\/blog\/#\/schema\/person\/ee29c62455ded10b2424fb9ca585e347\",\"name\":\"Avinash kumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.devopssupport.in\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/db01f522798b98f8f474a1dfdd200df1c0e7ada232088d7a8192e14919e4de0a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/db01f522798b98f8f474a1dfdd200df1c0e7ada232088d7a8192e14919e4de0a?s=96&d=mm&r=g\",\"caption\":\"Avinash kumar\"},\"sameAs\":[\"www.linkedin.com\/in\/avinash-kumar-150791240\"],\"url\":\"https:\/\/www.devopssupport.in\/blog\/author\/avinash\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to write Git Commit Messages - DevOps Support","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/","og_locale":"en_US","og_type":"article","og_title":"How to write Git Commit Messages - DevOps Support","og_description":"When developers first step into the world of Git, they often encounter a certain discomfort, especially when it comes to crafting meaningful commit messages. The Git commit...","og_url":"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/","og_site_name":"DevOps Support","article_published_time":"2023-10-17T16:17:08+00:00","article_modified_time":"2023-10-26T16:23:21+00:00","og_image":[{"url":"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/10\/image-22-1024x576.png","type":"","width":"","height":""}],"author":"Avinash kumar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Avinash kumar","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/#article","isPartOf":{"@id":"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/"},"author":{"name":"Avinash kumar","@id":"https:\/\/www.devopssupport.in\/blog\/#\/schema\/person\/ee29c62455ded10b2424fb9ca585e347"},"headline":"How to write Git Commit Messages","datePublished":"2023-10-17T16:17:08+00:00","dateModified":"2023-10-26T16:23:21+00:00","mainEntityOfPage":{"@id":"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/"},"wordCount":560,"commentCount":0,"image":{"@id":"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/#primaryimage"},"thumbnailUrl":"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/10\/image-22-1024x576.png","keywords":["Commit Message Comparisons","Git Commit Messages","How to write Git Commit Messages","Importance of Quality Commit Messages"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/","url":"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/","name":"How to write Git Commit Messages - DevOps Support","isPartOf":{"@id":"https:\/\/www.devopssupport.in\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/#primaryimage"},"image":{"@id":"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/#primaryimage"},"thumbnailUrl":"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/10\/image-22-1024x576.png","datePublished":"2023-10-17T16:17:08+00:00","dateModified":"2023-10-26T16:23:21+00:00","author":{"@id":"https:\/\/www.devopssupport.in\/blog\/#\/schema\/person\/ee29c62455ded10b2424fb9ca585e347"},"breadcrumb":{"@id":"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/#primaryimage","url":"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/10\/image-22.png","contentUrl":"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/10\/image-22.png","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/www.devopssupport.in\/blog\/how-to-write-git-commit-messages\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.devopssupport.in\/blog\/"},{"@type":"ListItem","position":2,"name":"How to write Git Commit Messages"}]},{"@type":"WebSite","@id":"https:\/\/www.devopssupport.in\/blog\/#website","url":"https:\/\/www.devopssupport.in\/blog\/","name":"DevOps Support","description":"DevOps Support | DevSecOps Support | SRE Support | MLOps SRE Support","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.devopssupport.in\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.devopssupport.in\/blog\/#\/schema\/person\/ee29c62455ded10b2424fb9ca585e347","name":"Avinash kumar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.devopssupport.in\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/db01f522798b98f8f474a1dfdd200df1c0e7ada232088d7a8192e14919e4de0a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/db01f522798b98f8f474a1dfdd200df1c0e7ada232088d7a8192e14919e4de0a?s=96&d=mm&r=g","caption":"Avinash kumar"},"sameAs":["www.linkedin.com\/in\/avinash-kumar-150791240"],"url":"https:\/\/www.devopssupport.in\/blog\/author\/avinash\/"}]}},"_links":{"self":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/1166","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/comments?post=1166"}],"version-history":[{"count":1,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/1166\/revisions"}],"predecessor-version":[{"id":1168,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/1166\/revisions\/1168"}],"wp:attachment":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/media?parent=1166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/categories?post=1166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/tags?post=1166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}