Skip to content

Git Commit Message Standards for ML ProjectsΒΆ

ChatGPT Prompt for Git Commit Message

To create a standardized git commit message using ChatGPT, provide the following details: the output of git diff (1) command (including one or more modified files), the JIRA story number, and optionally, any additional context. ChatGPT will generate the appropriate commit message based on these inputs.

  1. πŸ™‹β€β™‚οΈ To ensure you get enough information from git diff to create a rich git commit message with ChatGPT, use the following command: git diff -U10 my-script.py.

Example PromptΒΆ

Copy and paste the example prompt in ChatGPT or similar chat:

Generate git commands for staging and committing the following changes. Follow
the structure:

<type>(<scope>): <subject> [#issue_number | #jira_key]

Include all modified files in the `git diff` command. Provide the
complete `git add` and `git commit` commands, including the body and 
footer. Select the right git commit types with emojis. Limit 
comments to 72 characters per line and code lines to 79 characters. 

Output of `git diff` command:

[Please insert the output of the git diff here]

JIRA story number:

[Please enter the JIRA story number here]

Additional Context (Optional):
-----------------------------

[Please insert additional context]

Commit types:
-------------
Here’s the list of git commit types with emojis included:

### Commit Types:

- 🎨 Improve structure/format of the code
- ⚑️ Improve performance
- πŸ”₯ Remove code or files
- πŸ› Fix a bug
- πŸš‘οΈ Critical hotfix
- ✨ Introduce new features
- πŸ“ Add or update documentation
- πŸš€ Deploy stuff
- πŸ’„ Add or update the UI and style files
- πŸŽ‰ Begin a project
- βœ… Add, update, or pass tests
- πŸ”’ Fix security or privacy issues
- πŸ” Add or update secrets
- πŸ”– Release/Version tags
- 🚨 Fix compiler/linter warnings
- 🚧 Work in progress
- πŸ’š Fix CI build
- ⬇️ Downgrade dependencies
- ⬆️ Upgrade dependencies
- πŸ“Œ Pin dependencies to specific versions
- πŸ‘· Add or update CI build system
- πŸ“ˆ Add or update analytics or track code
- ♻️ Refactor code
- βž• Add a dependency
- πŸ”§ Add or update configuration files
- πŸ”¨ Add or update development scripts
- 🌍 Internationalization and localization
- ✏️ Fix typos
- πŸ’© Write bad code that needs to be improved
- βͺ️ Revert changes
- πŸ”€ Merge branches
- πŸ“¦οΈ Add or update compiled files or packages
- πŸ‘½ Update code due to external API changes
- 🚚 Move or rename resources (e.g., files, paths, routes)
- πŸ“„ Add or update license
- πŸ’₯ Introduce breaking changes
- 🍱 Add or update assets
- ♿️ Improve accessibility
- πŸ’¬ Add or update comments in source code
- πŸ—―οΈ Write code drunkenly
- πŸ§ͺ Add or update text and literals
- πŸ—ƒοΈ Perform database-related changes
- πŸ“ Add or update logs
- πŸ”‡ Remove logs
- πŸ‘€ Add or update contributor(s)
- πŸ› οΈ Improve user experience/usability
- πŸ—οΈ Make architectural changes
- πŸ“± Work on responsive design
- πŸ” Mock things
- πŸ₯š Add or update an easter egg
- βž• Add or update a .gitignore file
- πŸ§ͺ Add or update snapshots
- πŸ”¬ Perform experiments
- 🌐 Improve SEO
- πŸ›‘ Add or update types
- 🌱 Add or update seed files
- 🚩 Add, update, or remove feature flags
- ❗ Catch errors
- πŸ“² Add or update animations and transitions
- πŸ—‘οΈ Deprecate code that needs to be cleaned up
- πŸ”‘ Work on code related to authorization, roles, and permissions
- πŸ‘• Simple fix for a non-critical issue
- πŸ” Data exploration/inspection
- 🧹 Remove dead code
- 🚨 Add a failing test
- 🧠 Add or update business logic
- 🩺 Add or update health checks
- πŸ—οΈ Infrastructure-related changes
- 🀝 Improve developer experience
- πŸ’΅ Add sponsorships or money-related infrastructure
- βš–οΈ Add or update code related to multithreading or concurrency
- πŸ›‘οΈ Add or update code related to validation

Example of Expected Output:
---------------------------

git add mkdocs.yml poetry.lock pyproject.toml
git commit -m "feat(deps): add mkdocs versioning and testing dependencies [#JIRA-123]

Added dependencies for MkDocs versioning and testing to enhance
documentation and development workflows. Updated pyproject.toml
with the following:
- mkdocs-glightbox: to support image lightboxes in documentation
- mike: to manage multiple versions of documentation

Updated poetry.lock with new packages:
- importlib-resources: for resource management in tests
- mike: for documentation version management
- mkdocs-glightbox: for enhanced documentation visuals
- verspec: for flexible version handling

These changes improve documentation flexibility and testing coverage.

Footer notes:
- Consult package documentation for more details.
"

Generated Commit MessageΒΆ

ChatGPT might respond with:

git add utils/helpers.py
git commit -m "🎨 refactor(helpers): update pi precision and greeting format [#JIRA-123]

Updated the `calculate_area` function to use a more precise value
of pi (3.14159) for improved accuracy in area calculations. Also,
refined the `greeting` function to include a comma for better
readability in the output.

These changes enhance both the mathematical accuracy of area
calculations and the user experience with improved greeting
formatting.

Footer notes:
- Consider further enhancements to include localization
  for the greeting function.
"

Running the Git CommandΒΆ

To commit your changes with the generated message, run the following command in your terminal:

git add utils/helpers.py
git commit -m "🎨 refactor(helpers): update pi precision and greeting format [#JIRA-123]

Updated the `calculate_area` function to use a more precise value
of pi (3.14159) for improved accuracy in area calculations. Also,
refined the `greeting` function to include a comma for better
readability in the output.

These changes enhance both the mathematical accuracy of area
calculations and the user experience with improved greeting
formatting.

Footer notes:
- Consider further enhancements to include localization
  for the greeting function.
"

Include this admonition in your docs/how-to-guides/git-commit-message-standards.md file. This example explains how to request a standardized git commit message from ChatGPT, providing a detailed prompt and the expected output.

Introduction

Clear, informative commit messages are vital for effective team collaboration in machine learning projects. This guide provides standards and tools for creating standardized commit messages, including how to reference GitHub issue numbers or Jira keys. We follow the Conventional Commits specification.

Commit Message Structure

Commit messages should follow this structure:

<type>(<scope>): <subject> [#issue_number | #jira_key]

<body>

<footer>

ComponentsΒΆ

  • Type: Category of your commit.
  • Scope: Area of the codebase affected.
  • Subject: Brief description of changes, including issue tracker reference.
  • Body: Detailed explanation of changes and reasoning.
  • Footer: Additional notes or references.

Commit Types

Maintain consistency and organization with these commit types:

Type Description
feat New features or enhancements
fix Bug fixes
data Data processing or management changes
experiment Experimental or exploratory code changes
model Model development, testing, or deployment changes
docs Documentation additions or updates
refactor Performance enhancements without functionality changes
test Test writing or fixing
chore Routine tasks or non-production code updates
build Changes that affect the build system or external dependencies
ci Changes to CI configuration files and scripts
revert Reverts a previous commit
style Code style changes (formatting, missing semicolons, etc.)

Best Practices

  1. Concise Subject: Keep it short and descriptive.
  2. Imperative Mood: Phrase as an instruction, e.g., β€œfix” not β€œfixed”.
  3. Capitalized Subject Line: Start with a capital letter.
  4. No Period in Subject Line: Treat it as a title.
  5. Separate Body with a Blank Line: For tool compatibility.
  6. Explain What and Why: Not just how, in the body.
  7. Reference Issues and Pull Requests: Include relevant links for context.

ExamplesΒΆ

Here are some examples of commit messages that meet our standards:

feat(auth): add user authentication feature [#DATA123]

Added a new user authentication feature to enhance security.
This includes login, registration, and password recovery.

Footer: Reviewed by Jane Doe
fix(data): resolve data loading error [#GH45]

Fixed an issue where data loading was failing due to incorrect file paths.
Updated the file paths and added error handling.

Footer: Closes #GH45
docs: update API documentation

Improved the API documentation to include new endpoints and usage examples.
Fixed typos and clarified descriptions.

Footer: Documentation reviewed by the tech writing team

VS Code Extensions

Enhance commit message standardization with these VS Code extensions: - Gitmoji for VS Code: Add emoji to commit messages. Gitmoji. - Commit Message Editor: Enforce structured commit messages.

Reference for Best Practices

For an in-depth understanding, refer to Git Commit Message Best Practices.

Conclusion

By following these guidelines, our team can ensure a uniform and informative history in our repository, turning commit messages into a rich log that enhances clarity and streamlines collaboration.