# Branching Strategy This document describes the branch model, naming conventions, and merge/rebase workflows for **newzy**. ## Branches ### Long-lived branches | Branch | Purpose | Protected | | ----------- | -------------------------------------------------------------- | --------- | | `main` | Production-ready code. Always deployable. Receives releases. | Yes | | `develop` | Integration branch. All features land here before release. | Yes | ### Short-lived branches | Branch | Created from | Merged into | Used for | | ------------ | ------------ | ------------ | ------------------------------------------ | | `feature/*` | `develop` | `develop` | New features and enhancements | | `bugfix/*` | `develop` | `develop` | Bug fixes not yet in production | | `hotfix/*` | `main` | `main` | Critical fixes for production (immediate) | ## Naming Conventions - Use lowercase, kebab-case names: `feature/reader-view`, `bugfix/empty-feed-crash`. - Prefix with the type: `feature/`, `bugfix/`, `hotfix/`. - Keep the description short (2–4 words) and meaningful. - Optionally prefix with an issue number: `feature/123-article-search`. ## Merge and Rebase Workflows ### Feature development (rebase workflow) Keep feature branches linear by rebasing onto the latest `develop` before pushing a pull request: ```bash git checkout feature/reader-view git fetch origin git rebase origin/develop # resolve any conflicts, then: git rebase --continue git push --force-with-lease origin feature/reader-view ``` > **Rule:** only force-push branches that are still under active development and have not been merged. Never force-push `main` or `develop`. ### Merging into `develop` - Feature and bugfix branches are **squash-merged** into `develop` so each feature appears as one clean commit. - The commit message of the squash commit must be a valid Conventional Commit (see [commits.md](commits.md)). ### Merging into `main` (releases) - `develop` is merged into `main` with a **merge commit** (no squash, no rebase) to preserve the full feature history. - Example: `git merge --no-ff develop -m "release: cut v1.0.0"`. - Tag the resulting commit and push the tag. ### Hotfixes ```bash # 1. Branch off main git checkout main git pull --rebase origin main git checkout -b hotfix/feed-outage # 2. Fix, commit, and PR against main (merge commit) # 3. After merging into main, back-merge into develop git checkout develop git pull --rebase origin develop git merge --no-ff hotfix/feed-outage -m "merge: backport hotfix/feed-outage" git push origin develop ``` ## Conflict Resolution Strategy 1. **Rebase early, rebase often.** Resolve conflicts against `develop` at least once per day while a feature branch is active. 2. Resolve conflicts on the feature branch (the rebasing side), never by rewriting `main`/`develop`. 3. After resolving, run `git rebase --continue` and verify the app still works before pushing. 4. If a conflict cannot be resolved confidently, stop and ask for help in the pull request — do not guess. 5. The person who created the conflict (usually the branch doing the rebasing) owns the resolution. ## Do / Don't | Do | Don't | | --------------------------------------------------------- | ------------------------------------------------ | | Branch off `develop` (or `main` for hotfixes) | Commit directly to `main` or `develop` | | Keep branches short-lived (ideally under a week) | Push broken/unfinished code to protected branches| | Use `--force-with-lease` when force-pushing | Force-push shared or merged branches | | Rebase before opening a PR | Merge `develop` back into your feature branch |