This document describes the branching strategy, commit message conventions, and linear history maintenance for this project to ensure consistency and clarity across all contributions.
The project follows a branch-based workflow to organize features, fixes, and releases efficiently. Below is the branching strategy to be followed:
-
main
- Contains the latest stable release code.
- Only merged after review and passing tests.
- No direct commits allowed.
-
develop
- Tracks ongoing development work.
- Feature branches are merged here after approval.
- Regularly rebased from
main
to keep it up-to-date.
-
feature/{feature-name}
- Used for working on individual features.
- Branch naming convention:
feature/login-ui
orfeature/integration-x-api
.
-
bugfix/{issue-number}-{description}
- Dedicated for bug fixes.
- Example:
bugfix/42-login-issue
.
-
release/{version}
- Tracks release preparation (e.g.,
release/1.0.0
). - Bug fixes and last-minute adjustments merged here.
- Tracks release preparation (e.g.,
-
hotfix/{issue-number}-{description}
- Used for critical, time-sensitive patches to the
main
branch. - Example:
hotfix/99-crash-on-launch
.
- Used for critical, time-sensitive patches to the
The develop
and main
branches serve distinct roles in the project:
-
main
Branch:- Purpose: Holds the latest stable, production-ready code.
- Usage: Reflects the live version of the project. Only tested changes are merged here, typically via release branches or hotfixes. Direct commits are not allowed.
-
develop
Branch:- Purpose: Acts as the integration branch for new features and fixes.
- Usage: Aggregates work from feature branches and may contain unstable code. Code is tested here before being merged into
main
.
Aspect | main |
develop |
---|---|---|
Purpose | Production-ready code | Ongoing development and integration |
Stability | Always stable and deployable | May contain unstable or incomplete code |
Direct Commits | Not allowed (except hotfixes) | Allowed but discouraged |
This strategy helps maintain a stable production environment while allowing flexibility for development.
Consistent commit messages help with clear versioning and history tracking. The following format ensures that every commit is meaningful.
<type>(<scope>): <subject>
<body> # Optional but recommended
<footers> # Optional: references issues or breaking changes
feat(auth): add login page UI
fix(api): correct endpoint URL for orders
docs(readme): update installation instructions
- feat: A new feature
- fix: A bug fix
- docs: Documentation changes only
- style: Code style improvements (e.g., formatting)
- refactor: Code changes that neither fix a bug nor add a feature
- test: Adding or improving tests
- chore: Routine tasks like dependency updates
Optional but recommended. Indicates the area of the codebase affected (e.g., auth
, ui
, api
).
A short summary (imperative form, present tense) describing the change.
To maintain a clean and linear Git history, we use rebasing rather than merging for feature branches. This ensures that all commits are orderly and follow a chronological sequence.
-
Always rebase your branch on the latest
develop
ormain
branch:git checkout feature/my-new-feature git fetch origin git rebase origin/develop
-
Resolve conflicts if any appear during the rebase:
# After resolving conflicts git add . git rebase --continue
-
Force push to update your branch (because history is rewritten):
git push --force
-
Open a Pull Request (PR)
- Target:
develop
for feature/bugfix branches - Target:
main
for hotfixes
- Target:
-
Review Process:
- At least one team member must review your PR.
- Ensure all tests pass before requesting a review.
-
Rebase if needed:
Ifdevelop
has progressed since you started your feature, rebase your branch before merging. -
Squash and Merge:
Use squash and merge to ensure a linear history on thedevelop
andmain
branches. -
Tagging Releases:
For releases, the maintainer will tag themain
branch:git tag -a v1.0.0 -m "Release version 1.0.0" git push origin v1.0.0
-
Create a branch:
git checkout -b feature/login-ui
-
Rebase your branch:
git rebase origin/develop
-
Squash commits:
git rebase -i HEAD~<n>
-
Push force after rebasing:
git push --force
- Commit frequently: Make small, incremental commits with meaningful messages.
- Keep PRs focused: Avoid working on multiple issues in a single branch.
- Update branches regularly: Rebase frequently to avoid large merge conflicts.
- Avoid direct commits to
main
ordevelop
. All changes should go through pull requests.