Skip to content

Commit 0a1e2bb

Browse files
MetOffice#57 Update 02-branching.md
* Update 02-branching.md * Update episodes/02-branching.md Co-authored-by: Tim Pillinger <[email protected]> --------- Co-authored-by: Tim Pillinger <[email protected]>
1 parent c4821f3 commit 0a1e2bb

File tree

1 file changed

+38
-18
lines changed

1 file changed

+38
-18
lines changed

episodes/02-branching.md

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,28 @@ where the developers make changes.
6868
Once the feature is done, they submit a pull request and
6969
merge it into the `main` branch after review.
7070
Feature branches should be relatively short-lived.
71+
Each collaborator must have **write** level, or higher, permissions
72+
on the repository.
73+
There are 2 repositories for each person to be mindful of, ***local*** and ***origin***.
7174

7275
#### Pros
7376

74-
- Each feature is developed away from `main` so you don't affect production code
75-
- Multiple features can be developed in parallel feature branches
76-
- It's a simple model that's easy for those new to git and your project
77-
- Easy to set up with continuous integration testing and deployment
77+
- Developers create each feature away from `main` so you don't affect production code.
78+
- Developers can create many features in parallel feature branches.
79+
- It's a simple model that's easy for those new to git and your project.
80+
- Easy to set up with continuous integration testing and deployment.
7881

7982
#### Cons
8083

8184
- If you don't regularly merge changes to `main` into your feature branch
82-
it can become outdated, leading to merge conflicts
85+
it can become outdated, leading to merge conflicts.
8386
- You may struggle if you need to maintain multiple production versions
84-
simultaneously in the same repository
87+
simultaneously in the same repository.
8588

8689
The Feature Branch model is sometimes called GitHub Flow.
90+
Note that all branches and commits exist within the single GitHub, origin repository.
91+
They are visible to anyone who has read access to the repository.
92+
Any contributor can write to any branch that is not explicitly protected.
8793

8894
```mermaid
8995
---
@@ -142,14 +148,21 @@ to contribute to on GitHub in your personal space.
142148
You develop your changes using this fork.
143149
When a change is ready you open a pull request to contribute the changes
144150
back to the original repository.
151+
There are 3 repositories for each person to be mindful of,
152+
***local***, ***origin*** (your fork), and ***upstream*** (the original repository).
145153

146154
#### Pros
147155

148-
- Removes the need to give all collaborators adequate permissions
149-
on your repository
150-
- Only project maintainers can approve new code
156+
- Removes the need to give all collaborators write level or higher permissions
157+
on your repository.
158+
Anyone with read access to a repository can contribute.
159+
- Only project maintainers can approve new code.
151160
- You can use any other model within your main repository and
152-
forks to develop changes
161+
forks to develop changes.
162+
163+
All branches and commits exist within the collaborators fork, not the ***upstream*** repository. They are harder to find for anyone who has read access to the upstream repository.
164+
165+
Collaborators can use their fork to test more complex changes. For example testing github actions within a dummy-PR.
153166

154167
-----------------------------------------
155168

@@ -163,12 +176,12 @@ merged onto the `develop` and `main` branches.
163176

164177
#### Pros
165178

166-
- There is a clear purpose for each branch
167-
- Handles complex projects well
179+
- There is a clear purpose for each branch.
180+
- Handles complex projects well.
168181

169182
#### Cons
170183

171-
- Very steep learning curve, not suitable for novices
184+
- Steeper learning curve, novices may require more help.
172185

173186
```mermaid
174187
gitGraph
@@ -212,11 +225,18 @@ merged onto the `develop` and `main` branches.
212225

213226
## Recommendations
214227

215-
For small projects using a Feature Branch model is normally sufficient.
216-
If your team is large, or you expect external collaborators to contribute
217-
then we recommend developing using forks.
218-
Most open source projects require you to submit new code using a fork.
219-
The next few episodes will guide you through examples of both models.
228+
For repositories where collaborators are a small and trusted group the Feature Branch
229+
model is normally sufficient.
230+
231+
A Forking model is preferable if:
232+
- There are more collaborators, because the number of branches may become unwieldy.
233+
- There are external collaborators whose contribution is valued,
234+
but the repository owners need to retain control of the original.
235+
For this reason most open source projects use a Forking Model.
236+
237+
These working pattern are conventions not rules.
238+
It is easy to switch from one working pattern to the other.
239+
Or even to use the feature branch pattern for trusted colleagues and the forking pattern for outside contributors.
220240

221241
This wasn't an exhaustive list of branching models!
222242
You can find more information using the links below:

0 commit comments

Comments
 (0)