You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: white-paper/branching-strategies.qmd
+82-21Lines changed: 82 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -12,47 +12,47 @@ There is no need to define one single branching strategy for all of the reposito
12
12
13
13
## Basic git structure
14
14
15
-
The basic structure of a git repository relies on a principal branch called **main**, which will be duplicated in **sub-branches** that will in the end merged back to the main branch through a pull request.
15
+
The basic structure of a git repository relies on a principal branch called **main**, which will be duplicated in **feature branches** that will in the end merged back to the main branch through a pull request.
A branch can be locked using a [protection rule (see #13)](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/managing-a-branch-protection-rule#creating-a-branch-protection-rule).
176
+
Several possibilities can be applied. The most common is to use a tag release on the main branch to identify the milestone. It will save the main branch and clearly identify it as a milestone reached. This link provides more details about [tagging releases](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository/managing-releases-in-a-repository) on GitHub. Similar actions can be performed on other source code management platforms.
177
+
178
+
Another way is to duplicate the main branch and use a flag to identify the milestone, with the possibility to lock it. A branch can be locked using a [protection rule (see #13)](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/managing-a-branch-protection-rule#creating-a-branch-protection-rule).
177
179
178
180
## One main branch per milestone
179
181
@@ -247,6 +249,65 @@ flowchart TB
247
249
prc -->|"Merge common issue"| dmc
248
250
```
249
251
252
+
## Hot fixes
253
+
254
+
Hot fixes are urgent corrections that need to be applied to a specific milestone that has already been released or tagged. These fixes are typically critical bugs or issues discovered after a milestone has been finalized and need immediate attention.
255
+
256
+
When working with milestone branches, hot fixes can be applied in different ways depending on the branching strategy used:
257
+
258
+
### Hot fixes with tagged milestones
259
+
260
+
When milestones are identified using tags on the main branch, a hot fix should be created from the specific tag, applied, and then merged back to main. This ensures the fix is available for future milestones while also addressing the specific tagged milestone.
261
+
262
+
```{mermaid}
263
+
%%| label: fig-hotfix-tagged-structure
264
+
%%| fig-cap: "Hot fix workflow with tagged milestones"
When using separate milestone branches (e.g., CSR, DMC), hot fixes should be created from the specific milestone branch, applied, and then merged back to that milestone branch. If the fix is also relevant for other milestones or the main development branch, it can be cherry-picked or merged to those branches as well.
282
+
283
+
```{mermaid}
284
+
%%| label: fig-hotfix-milestone-structure
285
+
%%| fig-cap: "Hot fix workflow with milestone branches"
286
+
flowchart TB
287
+
milestone["Milestone branch<br/>(e.g., DMC #1)"]
288
+
hotfix("Hot fix branch")
289
+
pr>"Pull request"]
290
+
milestone --> hotfix
291
+
hotfix --> pr
292
+
pr -->|"Merge hot fix"| milestone
293
+
294
+
main["Main branch"]
295
+
pr -->|"Cherry-pick or merge"| main
296
+
```
297
+
298
+
### Best practices for hot fixes
299
+
300
+
-**Create from the milestone**: Always branch the hot fix from the specific milestone tag or branch that needs the fix.
301
+
-**Keep it minimal**: Hot fixes should contain only the essential changes needed to resolve the critical issue.
302
+
-**Test thoroughly**: Even though hot fixes are urgent, they should be tested before merging to avoid introducing new issues.
303
+
-**Document the fix**: Clearly document why the hot fix was necessary and what it addresses.
304
+
-**Merge back to main**: After applying the hot fix to the milestone, ensure it's also merged back to the main branch so future milestones include the fix.
305
+
-**Create a new tag**: After merging a hot fix to a milestone branch, create a new tag (e.g., v1.0.1) to mark the corrected version.
306
+
307
+
Hot fixes are essential for maintaining the integrity of released milestones while allowing development to continue on the main branch without disruption.
308
+
309
+
[This webpage](https://www.atlassian.com/git/tutorials/cherry-pick) provides more details about cherry-picking when using a devel branch.
310
+
250
311
## Pros and cons
251
312
252
313
Many other strategies can be defined, and the choice depends on the needs of each study team. Also, some of the strategies displayed above can be combined (for instance using a deven branch with a milestone main branch strategy).
0 commit comments