Skip to content

Commit 0d2ccf1

Browse files
committed
Update branching-strategies.qmd
1 parent 5c63071 commit 0d2ccf1

1 file changed

Lines changed: 82 additions & 21 deletions

File tree

white-paper/branching-strategies.qmd

Lines changed: 82 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,47 @@ There is no need to define one single branching strategy for all of the reposito
1212

1313
## Basic git structure
1414

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.
1616

1717
```{mermaid}
1818
%%| label: fig-basic-git-structure
1919
%%| fig-cap: "Basic Git branching structure"
2020
21-
%%{init: {'theme':'base', 'themeVariables': { 'primaryColor':'#87CEEB'}}}%%
21+
%%{init: {'theme':'base', 'themeVariables': { 'primaryColor':'#87CEEB'}}}%%
2222
gitGraph
2323
commit id: "Start"
24-
commit id: "Branch a"
25-
branch feature-a
26-
checkout feature-a
27-
commit id: "Commit a1"
24+
commit id: "Branch 1"
25+
branch feature-1
26+
checkout feature-1
27+
commit id: "Commit 1a"
2828
checkout main
29-
merge feature-a tag: "PR: Merge feature-a"
30-
commit id: "Merge A"
29+
merge feature-1 tag: "PR: Merge feature-1"
30+
commit id: "Merge 1"
3131
3232
checkout main
33-
commit id: "Branch b"
34-
branch feature-b
35-
checkout feature-b
36-
commit id: "Commit b1"
33+
commit id: "Branch 2"
34+
branch feature-2
35+
checkout feature-2
36+
commit id: "Commit 2a"
3737
checkout main
38-
merge feature-b tag: "PR: Merge feature-b"
39-
commit id: "Merge B"
38+
merge feature-2 tag: "PR: Merge feature-2"
39+
commit id: "Merge 2"
4040
```
4141

4242
```{mermaid}
4343
%%| label: fig-basic-git-structure
4444
%%| fig-cap: "Basic Git branching structure"
4545
flowchart TD
4646
main["Main branch"]
47-
feature-a("Feature A branch")
48-
feature-b("Feature B branch")
47+
feature-1("Feature 1 branch")
48+
feature-2("Feature 2 branch")
4949
PR1>"Pull request"]
5050
PR2>"Pull request"]
51-
main --> feature-a
52-
feature-a --> PR1
51+
main --> feature-1
52+
feature-1 --> PR1
5353
PR1 --> main
54-
main --> feature-b
55-
feature-b --> PR2
54+
main --> feature-2
55+
feature-2 --> PR2
5656
PR2 --> main
5757
```
5858

@@ -173,7 +173,9 @@ flowchart TB
173173
end
174174
```
175175

176-
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).
177179

178180
## One main branch per milestone
179181

@@ -247,6 +249,65 @@ flowchart TB
247249
prc -->|"Merge common issue"| dmc
248250
```
249251

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"
265+
%%{init: {'theme':'base', 'themeVariables': { 'primaryColor':'#87CEEB'}}}%%
266+
gitGraph
267+
commit id: "Initial"
268+
commit id: "Milestone 1"
269+
commit id: "Tag: v1.0"
270+
commit id: "Continue dev"
271+
branch hotfix-1.0.1
272+
checkout hotfix-1.0.1
273+
commit id: "Hot fix"
274+
checkout main
275+
merge hotfix-1.0.1 tag: "PR: Hot fix"
276+
commit id: "Tag: v1.0.1"
277+
```
278+
279+
### Hot fixes with milestone branches
280+
281+
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+
250311
## Pros and cons
251312

252313
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

Comments
 (0)