1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
|
.. _gitworkflow:
Git Workflow
============
This document describes the Git workflow used in the DataLab project,
based on a ``main`` branch, a ``develop`` branch, and feature-specific branches.
It also defines how bug fixes are managed.
.. note::
This workflow is a simplified version of the `Gitflow Workflow <https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow>`_.
It has been adapted to suit the needs of the DataLab project at the current stage of development.
In the near future, we may consider adopting a more complex workflow, e.g. by adding release branches.
Branching Model
---------------
Main Branches
^^^^^^^^^^^^^
- ``main``: Represents the stable, production-ready version of the project.
- ``develop``: Used for ongoing development and integration of new features.
Feature Branches
^^^^^^^^^^^^^^^^
- ``feature/feature_name``: Used for the development of new features.
- Created from ``develop``.
- Merged back into ``develop`` once completed.
- Deleted after merging.
Release Branch
^^^^^^^^^^^^^^
- ``release``: Represents the current maintenance line for patch releases.
- Created from ``main`` after a stable release when the first patch is needed.
- Accepts ``fix/xxx`` and ``hotfix/xxx`` branch merges.
- Merged back into ``main`` for each patch release tag (e.g., 1.0.1, 1.0.2).
- Reset or recreated when starting a new minor/major release cycle.
.. note::
The ``release`` branch is not versioned (no ``release/1.0.x``). It always
represents "the current maintenance line." When a new minor version is released
(e.g., 1.2.0), the old ``release`` branch is deleted and a new one is created
from the fresh tag when the first patch for 1.2.1 is needed.
Bug Fix Branches
^^^^^^^^^^^^^^^^
- ``fix/xxx``: Used for general bug fixes that are not urgent.
- Created from ``develop`` (for next feature release) or ``release`` (for patch release).
- Merged back into the originating branch once completed.
- Deleted after merging.
- ``hotfix/xxx``: Used for urgent production-critical fixes.
- Created from ``release`` (if exists) or ``main`` (if no ``release`` branch yet).
- Merged back into ``release`` or ``main``.
- The fix is then cherry-picked into ``develop``.
- Deleted after merging.
.. note::
Hotfixes (high-priority fixes) will be integrated in the next maintenance
release (X.Y.Z -> Z+1), while fixes (low-priority fixes) will be integrated
in the next feature release (X.Y -> Y+1).
Documentation Branches
----------------------
When working on documentation that is not related to source code
(e.g. training materials, user guides), branches should be named
using the ``doc/`` prefix.
Examples:
- ``doc/training-materials``
- ``doc/user-guide``
This naming convention improves clarity by clearly separating
documentation efforts from code-related development (features, fixes, etc.).
Workflow for New Features
-------------------------
1. Create a new feature branch from ``develop``:
.. code-block:: sh
git checkout develop
git checkout -b develop/feature_name
2. Develop the feature and commit changes.
3. Merge the feature branch back into ``develop``:
.. code-block:: sh
git checkout develop
git merge --no-ff develop/feature_name
4. Delete the feature branch:
.. code-block:: sh
git branch -d develop/feature_name
.. warning::
Do not leave feature branches unmerged for too long.
Regularly rebase them on ``develop`` to minimize conflicts.
Workflow for Regular Bug Fixes
------------------------------
For next feature release (target: ``develop``):
1. Create a bug fix branch from ``develop``:
.. code-block:: sh
git checkout develop
git checkout -b fix/bug_description
2. Apply the fix and commit changes.
3. Merge the fix branch back into ``develop``:
.. code-block:: sh
git checkout develop
git merge --no-ff fix/bug_description
4. Delete the fix branch:
.. code-block:: sh
git branch -d fix/bug_description
For current maintenance release (target: ``release``):
1. Create a bug fix branch from ``release``:
.. code-block:: sh
git checkout release
git checkout -b fix/bug_description
2. Apply the fix and commit changes.
3. Merge the fix branch back into ``release``:
.. code-block:: sh
git checkout release
git merge --no-ff fix/bug_description
4. Delete the fix branch:
.. code-block:: sh
git branch -d fix/bug_description
.. warning::
Do not create a ``fix/xxx`` branch from a ``develop/feature_name`` branch.
Always branch from ``develop`` or ``release`` to ensure fixes are correctly propagated.
.. code-block:: sh
# Incorrect:
git checkout develop/feature_name
git checkout -b fix/wrong_branch
.. code-block:: sh
# Correct:
git checkout develop
git checkout -b fix/correct_branch
Workflow for Critical Hotfixes
------------------------------
1. Create a hotfix branch from ``release`` (or ``main`` if no ``release`` branch exists):
.. code-block:: sh
git checkout release # or: git checkout main
git checkout -b hotfix/critical_bug
2. Apply the fix and commit changes.
3. Merge the fix back into ``release`` (or ``main``):
.. code-block:: sh
git checkout release # or: git checkout main
git merge --no-ff hotfix/critical_bug
4. Cherry-pick the fix into ``develop``:
.. code-block:: sh
git checkout develop
git cherry-pick <commit_hash>
5. Delete the hotfix branch:
.. code-block:: sh
git branch -d hotfix/critical_bug
.. warning::
Do not merge ``fix/xxx`` or ``hotfix/xxx`` directly into ``main`` without following the workflow.
Ensure hotfixes are cherry-picked into ``develop`` to avoid losing fixes in future releases.
Workflow for Patch Releases
----------------------------
When ready to release a patch version (e.g., 1.0.1, 1.0.2):
1. Ensure the ``release`` branch contains all desired fixes.
2. Merge ``release`` into ``main``:
.. code-block:: sh
git checkout main
git merge --no-ff release
3. Tag the release on ``main``:
.. code-block:: sh
git tag -a v1.0.1 -m "Release version 1.0.1"
git push origin main --tags
4. Keep the ``release`` branch for additional patches in the same minor version series.
Workflow for Minor/Major Releases
----------------------------------
When ready to release a new minor or major version (e.g., 1.1.0, 2.0.0):
1. Merge ``develop`` into ``main``:
.. code-block:: sh
git checkout main
git merge --no-ff develop
2. Tag the release on ``main``:
.. code-block:: sh
git tag -a v1.1.0 -m "Release version 1.1.0"
git push origin main --tags
3. Delete the old ``release`` branch (if exists):
.. code-block:: sh
git branch -d release
git push origin --delete release
4. Create a new ``release`` branch from ``main`` when the first patch for 1.1.1 is needed:
.. code-block:: sh
git checkout main
git checkout -b release
git push -u origin release
Best Practices
--------------
- Regularly **rebase feature branches** on ``develop`` to stay up to date:
.. code-block:: sh
git checkout develop/feature_name
git rebase develop
- Avoid long-lived branches to minimize merge conflicts.
- Ensure bug fixes in ``release`` or ``main`` are **always cherry-picked** to ``develop``.
- Clearly differentiate between ``fix/xxx`` (non-urgent fixes) and ``hotfix/xxx`` (critical production fixes).
- When creating the ``release`` branch, update release notes to indicate which version it targets (e.g., add a comment in the merge commit: "Create release branch for v1.0.x maintenance").
- The ``release`` branch always represents the current maintenance line. To know which version it targets, check the most recent tag on ``main`` or the release notes.
Takeaway
--------
This workflow ensures a structured yet flexible development process while keeping
``main`` stable and ``develop`` always updated with the latest changes.
The ``release`` branch provides a dedicated maintenance line for patch releases,
allowing ``develop`` to proceed with new features without interference. This solves
the problem of coordinating unreleased changes across the PlotPyStack ecosystem
(DataLab, Sigima, PlotPy, guidata, PythonQwt) by providing a stable branch for
CI testing during maintenance cycles.
|