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: episodes/02-branching.md
+38-18Lines changed: 38 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -68,22 +68,28 @@ where the developers make changes.
68
68
Once the feature is done, they submit a pull request and
69
69
merge it into the `main` branch after review.
70
70
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***.
71
74
72
75
#### Pros
73
76
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.
78
81
79
82
#### Cons
80
83
81
84
- 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.
83
86
- You may struggle if you need to maintain multiple production versions
84
-
simultaneously in the same repository
87
+
simultaneously in the same repository.
85
88
86
89
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.
87
93
88
94
```mermaid
89
95
---
@@ -142,14 +148,21 @@ to contribute to on GitHub in your personal space.
142
148
You develop your changes using this fork.
143
149
When a change is ready you open a pull request to contribute the changes
144
150
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).
145
153
146
154
#### Pros
147
155
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.
151
160
- 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.
153
166
154
167
-----------------------------------------
155
168
@@ -163,12 +176,12 @@ merged onto the `develop` and `main` branches.
163
176
164
177
#### Pros
165
178
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.
168
181
169
182
#### Cons
170
183
171
-
-Very steep learning curve, not suitable for novices
184
+
-Steeper learning curve, novices may require more help.
172
185
173
186
```mermaid
174
187
gitGraph
@@ -212,11 +225,18 @@ merged onto the `develop` and `main` branches.
212
225
213
226
## Recommendations
214
227
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.
220
240
221
241
This wasn't an exhaustive list of branching models!
222
242
You can find more information using the links below:
0 commit comments