๐ง Git Workflow & Conventional Commits¶
This guide covers our Git workflow and commit message standards for the CLOE Toolbox project.
๐ฟ Git Workflow¶
Branch Strategy¶
We use a feature branch workflow integrated with Azure DevOps:
graph LR
    A[main] --> B[feature/auth-module]
    B --> C[feat: add login]
    C --> D[test: add auth tests]
    D --> E[docs: update API docs]
    E --> F[merge to main]
    F --> G[v1.2.0]
    A --> H[hotfix/security-patch]
    H --> I[fix: security vulnerability]
    I --> J[merge to main]
    J --> K[v1.2.1]๐๏ธ Branch Naming Convention¶
Use descriptive branch names that clearly indicate the purpose:
| Branch Type | Pattern | Example | 
|---|---|---|
| ๐ Features | feature/description | feature/user-authentication | 
| ๐ Bug Fixes | fix/description | fix/memory-leak-processor | 
| ๐ Documentation | docs/description | docs/api-reference | 
| ๐ง Maintenance | chore/description | chore/update-dependencies | 
| ๐จ Hotfixes | hotfix/description | hotfix/security-patch | 
๐ Conventional Commits¶
We follow the Conventional Commits specification for consistent commit messages.
๐ฏ Commit Message Format¶
๐ Commit Types¶
| Type | Description | Example | 
|---|---|---|
| feat | โจ New feature | feat: add user login functionality #1234 | 
| fix | ๐ Bug fix | fix: resolve memory leak in data processor #1235 | 
| docs | ๐ Documentation | docs: add API reference for auth module #1236 | 
| style | ๐ Code style changes | style: format code according to PEP 8 #1237 | 
| refactor | โป๏ธ Code refactoring | refactor: simplify user validation logic #1238 | 
| test | ๐งช Adding tests | test: add unit tests for auth module #1239 | 
| chore | ๐ง Maintenance | chore: update dependencies to latest versions #1240 | 
| perf | โก Performance improvements | perf: optimize database query performance #1241 | 
| ci | ๐ท CI/CD changes | ci: add automated security scanning #1242 | 
| build | ๐ฆ Build system changes | build: update build configuration #1243 | 
๐ Scope (Optional)¶
Specify the component or module affected:
feat(auth): add OAuth2 integration #1234
fix(database): resolve connection timeout issue #1235
docs(api): update endpoint documentation #1236
๐ก Commit Examples¶
fix: resolve memory leak in data processor #1235
The data processor was not properly cleaning up resources
after processing large datasets, causing memory usage to grow
continuously.
- Add proper resource cleanup in finally blocks
- Implement garbage collection hints
- Add memory usage monitoring
Fixes #1235
๐ Azure DevOps Integration¶
๐ Linking Work Items¶
Always link commits to Azure DevOps work items using the ID:
# Feature commits
git commit -m "feat: implement data validation #1234"
# Multiple work items
git commit -m "fix: resolve authentication issues #1234 #1235"
# Different linking keywords
git commit -m "feat: add new endpoint (closes #1234)"
git commit -m "fix: memory leak (fixes #1235)"
git commit -m "docs: API reference (resolves #1236)"
๐ท๏ธ Keywords for Work Item Actions¶
| Keyword | Action | Usage | 
|---|---|---|
| #1234 | Link | Links commit to work item | 
| fixes #1234 | Close | Closes work item when merged | 
| closes #1234 | Close | Closes work item when merged | 
| resolves #1234 | Close | Closes work item when merged | 
๐ ๏ธ Git Best Practices¶
๐ฆ Commit Guidelines¶
- ๐ฏ Atomic Commits: Each commit should represent a single logical change
- ๐ Clear Messages: Write descriptive commit messages for future developers
- ๐ Link Work Items: Always include Azure DevOps work item IDs
- ๐ Reasonable Size: Keep commits focused and reasonably sized
๐ Before Committing¶
- ๐งช Run Tests: Ensure all tests pass
- ๐งน Check Code Quality: Run linting and formatting
- 
๐ Update Documentation: Update relevant documentation 
- 
๐ Review Changes: Double-check what you're committing 
๐ Git Flow Commands¶
๐ Starting New Work¶
# Create and switch to feature branch
git checkout -b feature/your-feature-name
# Link initial commit to work item
git commit -m "feat: initial setup for new feature #1234"
๐พ Regular Development¶
# Stage specific files
git add src/module.py tests/test_module.py
# Commit with conventional format
git commit -m "feat: add data validation logic #1234"
# Push to remote
git push origin feature/your-feature-name
๐ Preparing for PR¶
# Rebase on latest main
git fetch origin
git rebase origin/main
# Interactive rebase to clean up commits (if needed)
git rebase -i origin/main
# Force push (only for feature branches)
git push --force-with-lease origin feature/your-feature-name
๐ Advanced Git Techniques¶
๐ง Interactive Rebase¶
Use interactive rebase to clean up commit history before creating PRs:
# Rebase last 3 commits interactively
git rebase -i HEAD~3
# Common rebase commands:
# pick    = use commit
# reword  = use commit, but edit message
# edit    = use commit, but stop for amending
# squash  = use commit, but meld into previous commit
# drop    = remove commit
๐ฏ Cherry-picking¶
Apply specific commits to other branches:
# Apply commit to current branch
git cherry-pick <commit-hash>
# Apply multiple commits
git cherry-pick <commit1> <commit2>
๐ Useful Git Commands¶
# View commit history with graph
git log --oneline --graph --decorate
# Search commit messages
git log --grep="feat"
# Find when a bug was introduced
git bisect start
git bisect bad HEAD
git bisect good <known-good-commit>
# Show changes in a commit
git show <commit-hash>
# Compare branches
git diff main..feature/branch-name
Pro Tips
- Use git commit --amendto modify the last commit message
- Create aliases for frequently used commands in .gitconfig
- Use git stashto temporarily save work when switching branches
- Set up VS Code as your default Git editor for better commit message writing
Important Reminders
- Never force push to mainbranch
- Always include work item IDs in commit messages
- Keep commit messages under 72 characters for the first line
- Use present tense in commit messages ("add" not "added")