Skip to content

Latest commit

 

History

History
397 lines (273 loc) · 7.88 KB

File metadata and controls

397 lines (273 loc) · 7.88 KB

Git Guidelines

Defines common Git conventions and workflows used across Tobit.Labs projects.

The goal is to keep repositories, branches, and commit histories consistent and easy to understand.

Overview

  1. Branch Strategy
  2. Environment Branches
  3. Feature Branches
  4. Branch Naming
  5. Commits
  6. Gitmoji
  7. Commit Messages
  8. GitKraken AI
  9. Merging
  10. General Principles

Branch Strategy

Depending on the project, one of two branching strategies can be used.

Environment-Based Workflow

Projects with multiple deployment environments use dedicated branches for each environment:

develop
   │
   ▼
  qa
   │
   ▼
staging
   │
   ▼
 main

Changes move through the environments in this order:

develop → qa → staging → main

Each branch represents a different level of stability.

Feature-Based Workflow

Projects that do not require dedicated environment branches can use feature branches directly.

main
├── feature/user-settings
├── feature/calendar
├── feature/message-preview
└── fix/navigation-history

Feature branches should be short-lived and merged back into the appropriate target branch once the work is complete.


Environment Branches

develop

The develop branch contains the latest development state.

New development work is integrated here before being promoted to higher environments.

feature/*
     │
     ▼
  develop

qa

The qa branch represents the version currently available for quality assurance and testing.

Changes should normally reach qa through develop.

develop → qa

staging

The staging branch represents a release candidate that is intended to be close to the production version.

Only changes that have passed the previous development and QA stages should normally reach this branch.

develop → qa → staging

main

The main branch represents the production-ready state of the project.

Changes should only reach main after passing the required previous environments.

develop → qa → staging → main

Avoid using main as an active development branch.


Feature Branches

Development that should not happen directly on an environment branch should be done in a dedicated branch.

Example:

develop
   │
   └── feature/user-settings

After the feature is complete:

feature/user-settings
        │
        ▼
     develop

Feature branches isolate unfinished work and prevent incomplete changes from affecting other developers or environments.


Branch Naming

Branch names should clearly communicate their purpose.

Use lowercase names and kebab-case.

Features

feature/user-settings
feature/calendar-navigation
feature/message-preview

Bug Fixes

fix/navigation-history
fix/message-rendering
fix/calendar-selection

Refactoring

refactor/navigation
refactor/message-store

Maintenance

chore/update-dependencies
chore/cleanup-assets

Keep branch names short but descriptive.

Avoid:

feature/test
fix/bug
new-feature
michael-test
changes

Commits

A commit should represent one logical change.

Prefer several focused commits over one large commit containing unrelated changes.

For example:

✨ Add user settings dialog
🐛 Fix dialog closing behavior
♻️ Extract settings state into hook

instead of:

changes

or:

✨ Add settings, fix navigation, update dependencies and refactor dialog

Keep Commits Focused

A commit should ideally be understandable on its own.

Do not intentionally combine unrelated:

  • features,
  • bug fixes,
  • refactorings,
  • formatting changes,
  • dependency updates,
  • or generated files

into the same commit.


Gitmoji

Commit messages use Gitmoji to communicate the type of a change at a glance.

The Gitmoji should be placed at the beginning of the commit message.

<gitmoji> <message>

Examples:

✨ Add user settings
🐛 Fix navigation history
♻️ Refactor message handling
💄 Update dialog styling
📝 Update documentation
🔧 Update configuration
⬆️ Update dependencies
🔥 Remove deprecated component

Common Gitmojis include:

Gitmoji Purpose
Introduce a new feature
🐛 Fix a bug
♻️ Refactor code
💄 Update UI or styles
📝 Add or update documentation
🔧 Add or update configuration
⬆️ Upgrade dependencies
⬇️ Downgrade dependencies
🔥 Remove code or files
🚚 Move or rename resources
⚡️ Improve performance
🔒️ Fix security or privacy issues
🚑️ Critical hotfix
🎨 Improve code structure or formatting
Add or update tests
🚀 Deploy changes

Use the Gitmoji that best represents the primary purpose of the commit.

Do not add multiple Gitmojis simply because a commit touches several files.


Commit Messages

Commit messages should be short, descriptive, and written in imperative form.

Prefer:

✨ Add calendar navigation
🐛 Fix message selection
♻️ Extract navigation logic
💄 Improve mobile layout

Avoid:

✨ Added calendar navigation
🐛 Fixed some stuff
♻️ Refactoring
💄 CSS changes

Describe What Changed

The message should provide enough context to understand the purpose of the commit without inspecting every changed file.

Prefer:

🐛 Prevent duplicate message requests

over:

🐛 Fix bug

Do Not Include Unnecessary Details

The commit title should remain concise.

Additional context can be provided in the commit body when necessary.

🐛 Prevent duplicate message requests

Avoid starting another request while the previous request for the
same message is still pending.

GitKraken AI

When using GitKraken AI to generate commit messages, use the provided prompt to ensure generated messages follow the conventions defined above.

GitKraken Commit Message Prompt


Merging

Changes should be merged into the branch representing the next appropriate stage.

For the environment-based workflow:

feature/*
    ↓
develop
    ↓
   qa
    ↓
staging
    ↓
 main

Do not skip environments unless there is a specific reason to do so.

A normal feature should therefore not be merged directly from:

feature/* → main

when the project uses the full environment workflow.

Resolve Conflicts Carefully

Merge conflicts should be resolved based on the intended resulting behavior.

Do not automatically accept one side of a conflict without understanding both changes.

After resolving conflicts, verify that the resulting code still works as intended.


General Principles

When working with Git:

  1. keep commits small and logically focused,
  2. use Gitmoji consistently,
  3. write descriptive commit messages,
  4. use descriptive branch names,
  5. keep unfinished work out of stable branches,
  6. move changes through the defined environments,
  7. avoid unrelated changes in the same commit,
  8. and keep the repository history understandable for other developers.

A good Git history should make it possible to understand what changed and why without having to reconstruct the development process from the code alone.