Skip to main content

Git

Commit Guidelines

Every commit should be meaningful and easy to understand. A good commit should describe one clear change or purpose so that others can review history quickly.

Principles

  • Keep commits small and focused on a single task or concern.
    • Good example: "Fix button alignment on the login form"
    • Bad example: "Update the whole UI"
  • Write commits that explain what changed and why it was needed.
    • Good example: "Add validation to prevent empty email submissions"
    • Bad example: "Improve form behavior"
  • Avoid mixing unrelated changes in the same commit.
    • Good example: "Refactor sidebar styling"
    • Bad example: "Refactor sidebar styling and update payment flow"
  • Do not commit incomplete or experimental work unless it is clearly marked and temporary.
    • Good example: "WIP: add draft search filter"
    • Bad example: "Add search filter"
  • Make sure the commit history remains readable for future reference.
    • Good example: "Fix mobile navigation crash"
    • Bad example: "misc changes"

Commit Guidelines

  • Use a short, clear subject line.
    • Good example: "Fix broken navbar spacing"
    • Bad example: "This commit fixes a lot of small issues in the navbar today"
  • Start the subject with a verb such as Add, Fix, Update, Remove, or Refactor.
    • Good example: "Refactor API client for reuse"
    • Bad example: "A big cleanup of the API client"
  • Keep the subject line concise and specific.
    • Good example: "Add password reset validation"
    • Bad example: "Add some validation for password reset and related things"
  • Add a short body only when the reason for the change needs extra context.
    • Good example:
      • Subject: "Fix crash on profile page"
      • Body: "The page crashed when the profile data was missing."
    • Bad example:
      • Subject: "Fix profile page"
      • Body: "Made a bunch of changes."
  • Every commit must be signed.
    • Good example: "git commit -S -m "Fix crash on profile page""
    • Bad example: "git commit -m "Fix crash on profile page""
    • Setup guide: GitHub GPG key setup guide
    • After generating your key, configure Git to use it and enable signed commits for your repository.

Code Example

git commit -m "Fix crash when opening settings on small screens"

This shows a clear, specific commit message that explains the change directly.

Avoid

  • update
  • fix stuff
  • misc changes
  • wip
  • stuff

A commit should help someone reading the project history understand the intent of the change without needing extra context.