Git Commit Messages | Best Practices & Guidelines

Aditya PatilAditya Patil
7 min read

Here’s a concise, “standard practice” cheat-sheet you can follow for Git commit messages. It blends Conventional Commits style (widely adopted) with practical DevOps/Jira usage.


Core Format

<type>(<optional-scope>): <short imperative summary>
<blank line>
<body: what & why, not just how>
<blank line>
<footer: issue refs, breaking changes, co-author>

Imperative mood (“Add”, “Fix”, “Update”), max ~50 chars subject, wrap body ~72 chars, no trailing period in subject.


Standard <type> Keywords (top tier)

TypeWhen to UseExample Subject
featNew user-visible feature/functionality.feat(auth): add OAuth2 login
fixBug fix (user-impacting defect).fix(api): handle null user_id
docsDocumentation only.docs(readme): add setup for EKS
styleFormatting, whitespace, lint fixes; no code behavior change.style: run gofmt over handlers
refactorCode restructure w/o behavior change (cleanups, modularization).refactor(db): extract conn pool
perfPerformance improvement.perf(cache): reduce redis calls
testAdd/update tests only.test(payments): add retry cases
buildBuild system, packaging, artifact changes (Maven, npm, Dockerfile).build(docker): multi-stage image
ciCI/CD pipeline config (Jenkinsfile, GitHub Actions, Argo, etc.).ci: add security scan stage
choreMaintenance tasks that don’t fit others (deps bumps, cleanup).chore: bump terraform modules
revertRevert a prior commit. Include hash in body.revert: feat(auth) oauth2 login

Extended Scenarios (DevOps-Friendly)

ScenarioRecommended PrefixExample
Infra as Code change (Terraform, CloudFormation) that affects runtimeinfra or build/chore (team choice)infra(vpc): add nat gateway in ap-south-1
Kubernetes manifests / Helm chart updatebuild/infrabuild(helm): update image tag to v1.4.2
Secrets rotation / config changechore/configchore(config): rotate rds creds
Security patch (CVE fix, policy hardening)sec or fixsec(openssl): patch CVE-2025-1234
Observability config (Prometheus, Grafana dashboards)chore/obs or build/monitoringchore(obs): add 95p latency panel
Release version bumpchore(release)chore(release): cut 1.3.0
Hotfix to productionfix! or hotfix (team style)fix!(prod): rollback bad migration

Note: Custom types (infra, sec, obs) are fine if your team agrees and tooling supports them. Otherwise map to closest core type.


Good Subject Verb Starters

Add, Update, Remove, Fix, Refactor, Rename, Improve, Optimize, Configure, Revert, Bump, Merge.


Referencing Issues / Tickets

Add in footer (preferred) or inline after summary if policy requires:

Footer style:

Closes #123
Refs JIRA-456

Subject inline (short teams):

feat(auth): add MFA (JIRA-789)

Multi-Line Example

feat(payments): support UPI autopay

Adds recurring UPI mandate flow for Indian merchants.
Includes gateway callback handler and retry logic.

Closes FIN-3421.

Quick Do / Don’t

Do

  • Write the why in body (context helps code reviewers + future you).

  • Group related changes; avoid “misc fixes”.

  • Use scope for service/module (auth, api, ui, infra, helm, cicd).

Don’t

  • Combine unrelated feature + refactor.

  • Write past tense (“Added”); use imperative (“Add”).

  • Dump auto-generated build logs in commit message.


Fast Mapping Cheat (copy/paste)

feat: new feature
fix: bug fix
docs: docs only
style: formatting
refactor: code restructure
perf: performance boost
test: tests only
build: build/packaging
ci: pipeline/automation
chore: maintenance
revert: rollback commit

Need this as a reusable snippet for your team’s README/contributing guide or a commit-lint config? Say the word and I’ll generate it.


Additional Prefixes (Optional)

Some teams add custom scopes:

  • feat(auth): add JWT token generation

  • fix(ui): resolve button alignment


Best Practices for Commit Messages

  1. Use imperative tone – "add feature" not "added feature".

  2. Keep subject < 50 characters, and capitalize the first letter.

  3. Body (optional) – Explain why the change was made, not just what.

Example:

feat: add password reset endpoint

- Implemented API /reset-password
- Integrated with AWS SES for email
- Added unit tests

Scenarios & Commit Examples

  • New feature: feat: add S3 storage support

  • Bug fix: fix: handle timeout issue in API calls

  • Hotfix in production: fix: patch security vulnerability in JWT

  • Code cleanup: chore: remove deprecated functions

  • Pipeline change: ci: add Slack notification for failed builds

  • Database migration: feat(db): add migration script for user table


Git commit message best practices and examples specifically for a Cloud & DevOps Engineer, covering the types of tasks you commonly handle — infra provisioning, CI/CD, observability, containerization, scripting, etc.

Git Commit Message Convention for Cloud & DevOps Engineers

Format:

php-templateCopyEdit<type>(<scope>): <short summary>

[Optional detailed body]

🔧 1. Infrastructure as Code (Terraform, CloudFormation)

ScenarioCommit Message
Adding new modulefeat(iac): add VPC module with public/private subnets
Modifying resourcesrefactor(iac): update EC2 instance type to t4g.small
Removing unused codechore(iac): remove legacy S3 bucket resource
Fixing syntax errorsfix(iac): correct variable reference in outputs.tf

🛠️ 2. CI/CD Pipeline Changes (Jenkins, GitHub Actions, Azure DevOps)

ScenarioCommit Message
Add pipelinefeat(ci): add GitHub Actions workflow for backend
Fix build failurefix(ci): update Docker build context path
Modify Jenkinsfilechore(ci): parameterize Jenkinsfile for env selection
Add Slack alertsfeat(ci): notify #devops-alerts on build failure

☁️ 3. Cloud Configurations (AWS/GCP/Azure)

ScenarioCommit Message
Add new AWS resourcefeat(cloud): add RDS instance for MySQL DB
Update IAM permissionsfix(cloud): grant S3 write access to Lambda role
Delete unused resourcechore(cloud): remove unused ECR repo

🐳 4. Containerization (Docker, Kubernetes)

ScenarioCommit Message
Create Dockerfilefeat(docker): add Dockerfile for backend service
Optimize imageperf(docker): reduce image size using multi-stage build
Add Helm chartfeat(k8s): add Helm chart for payments service
Modify deploymentrefactor(k8s): increase replica count to 3
Fix readiness issuefix(k8s): add proper readinessProbe for backend

🔒 5. Security & Compliance

ScenarioCommit Message
Add security group rulefeat(security): allow HTTPS on port 443 in SG
Fix vulnerabilityfix(security): upgrade Log4j to safe version
Enable encryptionfeat(security): enable encryption on S3 bucket

📈 6. Monitoring & Observability (Prometheus, CloudWatch, Grafana)

ScenarioCommit Message
Add metricsfeat(monitoring): expose HTTP request metrics to Prometheus
Update dashboardchore(grafana): update dashboard with new latency panel
Fix alert rulefix(alert): correct threshold for memory usage alert

📜 7. Automation Scripts (Shell, Python, Lambda)

ScenarioCommit Message
Add automationfeat(script): automate backup of EBS snapshots
Modify logicrefactor(script): replace curl with AWS CLI for uploads
Fix errorfix(script): handle null env vars in deploy.sh

📄 8. Documentation & Runbooks

ScenarioCommit Message
Add new docdocs: add deployment guide for QA environment
Update existingdocs: update Terraform module usage instructions
Fix typodocs: fix typo in RDS connection string example

🧪 9. Testing Infrastructure

ScenarioCommit Message
Add test env configfeat(env): add test namespace in EKS
Add pipeline test steptest(ci): add security scan using Trivy
Fix flaky test stepfix(ci): increase timeout for integration test step

🔁 10. Reverting or Rollbacks

ScenarioCommit Message
Revert breaking changerevert: revert "feat(k8s): add HPA config to backend"
Rollback configchore: rollback to stable config for staging

📌 Quick Summary Table

TypeUse CaseExample
feat:New infra, pipeline, resourcefeat(iac): add CloudFront CDN config
fix:Fix errors, bugs, issuesfix(k8s): resolve crashloop for init container
refactor:Code restructure, cleanuprefactor(script): optimize backup loop
chore:Maintenance tasks, deletionschore: remove unused Lambda trigger
ci:Pipeline changesci: update Jenkins agent version
build:Dockerfile, image-relatedbuild: add image tag with Git SHA
perf:Performance improvementsperf: reduce DB startup time on RDS
docs:Documentationdocs: add runbook for restoring backups
test:Infra test cases, pipeline checkstest: add sanity check to deployment step
revert:Undo previous commitrevert: revert change to Nginx config
0
Subscribe to my newsletter

Read articles from Aditya Patil directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Aditya Patil
Aditya Patil

Hi, I'm Aditya — a Cloud & DevOps Engineer passionate about automating everything from CI/CD pipelines to multi-cloud infrastructure. I specialize in AWS, Kubernetes, Terraform, and GitOps tools like Argo CD. I’ve helped teams scale applications, cut cloud costs by 90%, and build disaster-ready infra. I love sharing real-world DevOps lessons, cloud cost optimization tips, and infrastructure design patterns. Let’s connect and simplify the cloud — one YAML file at a time ☁️⚙️