Git & GitHub Workflow
Team Guidelines ยท Version 4.0 ยท Last Updated: October 2025
Contents
1. Purpose
This document defines the standard Git & GitHub workflow for all firmware teams. It ensures code integrity, traceability, and predictable release management across projects by clearly defining repository structure, branching and merging strategies, and role-based responsibilities (Admin / Manager / Developer).
2. Repository Naming and Structure
Naming Convention
| Type | Naming Format | Example |
|---|---|---|
| Firmware source code | projectname-fw | sensorhub-fw |
| Documentation | projectname-doc | sensorhub-doc |
| Shared library | libname-fwlib | motorctrl-fwlib |
| Test or simulation | projectname-test | sensorhub-test |
projectname-doc repository. Do not commit binaries, SDKs, build artifacts, or secrets.Repository Folder Layout
projectname-fw/
โ
โโโ docs/ # Developer-facing notes
โโโ src/ # Firmware source
โโโ include/ # Headers
โโโ build/ # Build scripts (no compiled outputs)
โโโ tools/ # Flashing or analysis utilities
โโโ tests/ # Unit/integration tests
โโโ .gitignore
โโโ README.md
โโโ LICENSE
โโโ CHANGELOG.md3. Branching Model Overview
feature / bugfix branches โ development โ staging โ productionMain Branches
| Branch | Purpose | Access |
|---|---|---|
| development | Active development branch. All new work starts here. | All Developers |
| staging | Integration and field-testing branch. | Managers only |
| production | Stable, released firmware in production. | Admins & Managers |
Developer Branches
feature/feature-name
bugfix/ISSUE-123
hotfix/critical-security-patch
docs/update-api-documentationmaster unless you are a repository maintainer. Maintain strict protection rules.4. Roles, Responsibilities & Permissions
๐ Admin
Responsible for overall integrity of repositories
Responsibilities:
- Create and configure repositories
- Enforce branch protections
- Manage teams and CI/CD pipelines
- Approve merges to
production - Maintain security policies (2FA, signed commits)
- Ensure no secrets in repos
๐ Manager / Maintainer
Acts as technical lead for the project
Responsibilities:
- Review PRs to
development - Integrate stable work into
staging - Maintain changelogs
- Supervise testing cycles
- Tag releases
- Coordinate with developers
๐ป Developer
Builds, tests, and submits code via pull requests
Typical Workflow:
git checkout -b feature/add-usb-bootloader
# work locally, commit often
git fetch origin
git merge origin/development
git push origin feature/add-usb-bootloader
# open PR -> development5. Versioning & Releases
Semantic Versioning
Use semantic versioning: MAJOR.MINOR.PATCH (e.g., v2.1.0)
Breaking changes, incompatible API changes
New features, backward compatible
Bug fixes, backward compatible
Release Process
git tag -a v2.1.0 -m "Release v2.1.0 โ New USB stack"
git push origin v2.1.0CHANGELOG.md with release notes.CHANGELOG.md Format
# Changelog
## [2.1.0] - 2025-11-06
### Added
- New USB bootloader support
- Over-the-air (OTA) update capability
- Temperature calibration interface
### Changed
- Improved WiFi reconnection logic
- Optimized power consumption in sleep mode
### Fixed
- Sensor timeout issue in low-power mode
- Memory leak in MQTT client
## [2.0.0] - 2025-10-15
### Breaking Changes
- Changed API for sensor configuration
- Removed deprecated functions from v1.x
### Added
- RTOS support with FreeRTOS
- Multi-sensor support6. Git Submodules
Use submodules for shared libraries intended for reuse across projects. This keeps common code synchronized and version-controlled.
Adding a Submodule
# Add submodule to your project
git submodule add https://github.com/yourorg/motorctrl-fwlib lib/motorctrl
# Commit the submodule reference
git commit -m "Add motorctrl library as submodule"Cloning with Submodules
# Option 1: Clone and init submodules in one command
git clone --recurse-submodules https://github.com/yourorg/project-fw
# Option 2: Clone first, then init submodules
git clone https://github.com/yourorg/project-fw
cd project-fw
git submodule init
git submodule updateUpdating Submodules
# Enter submodule directory
cd lib/motorctrl
# Pull latest changes
git pull origin main
# Return to main project
cd ../..
# Commit the submodule update
git add lib/motorctrl
git commit -m "Update motorctrl library to v1.5.0"
git push7. Best Practices & Common Pitfalls
โ Do's
development clean and buildableEvery commit to development should compile and pass basic tests
.gitignore aggressivelyExclude build outputs, IDE files, OS-specific files, and temporary files
Each commit should represent one logical change with clear description
Always fetch and merge latest changes before pushing your work
All code must be reviewed by at least one other team member
๐ซ Don'ts
Force pushing rewrites history and breaks collaboration
Use .gitignore and environment variables for configuration
All PRs must pass review and CI/CD checks before merging
Use pull requests for all changes to development, staging, and production
.gitignore Template
# Build outputs
build/
*.bin
*.hex
*.elf
*.map
# IDE files
.vscode/
.idea/
*.code-workspace
# OS files
.DS_Store
Thumbs.db
# Temporary files
*.tmp
*.log
*.swp
# Secrets
secrets.h
config_local.h
*.key
*.pem8. Security & Access Matrix
| Role | Create Repos | Merge to Dev | Merge to Staging | Merge to Production | Tag Releases | Manage Access |
|---|---|---|---|---|---|---|
| Admin | โ | โ ๏ธ | โ | โ | โ | โ |
| Manager | โ | โ | โ | โ (with Admin) | โ | โ |
| Developer | โ | โ (via PR) | โ | โ | โ | โ |
Security Best Practices
Require two-factor authentication for all team members
Use GPG signing to verify commit authenticity
Use environment variables or secret management tools
Require PR reviews, passing CI, and up-to-date branches
๐ฏ Quick Reference: Developer Daily Workflow
git pull origin developmentgit checkout -b feature/my-workgit add . && git commit -m "message"git merge origin/developmentgit push -u origin feature/my-work