Skip to content

Commit c1c0d77

Browse files
committed
Trying to get the order correct in the mermaid diagram
1 parent 0419f97 commit c1c0d77

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

docs/branches.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ graph LR
278278

279279
Merge 'cool-feature' to 'master' (3-way merge)
280280

281+
3-way merges use a dedicated commit for connecting the two merge histories. The name comes from the fact that Git uses three commits to generate the merge commit: the two branch tips and their common ancestor.
282+
281283
```mermaid
282284
graph LR
283285
@@ -335,6 +337,74 @@ graph LR
335337

336338
---
337339

340+
### Example, fast-forward merging
341+
342+
If there is a linear path from the current branch tip and to the target branch, then it is possible to do a fast-forward merge. Git is not really merging the branches, just integrating the histories, i.e. it moves “fast forward” the current branch tip up to the target branch tip.
343+
344+
When doing so the commit histories are combined and all commit histories can be reached from the current tip. An example would be to do a fast-forward merge of a feature into master/main.
345+
346+
A fast-forward merge is not possible if the branches have diverged, like in the previous example. This means that there is no linear path to the target branch and Git has to combine them via a 3-way merge.
347+
348+
This shows an example where a fast-forward merge would work.
349+
350+
Before FF merge:
351+
352+
```mermaid
353+
graph LR
354+
355+
master["master"]
356+
style master fill:#ffffff,stroke:#ffffff
357+
nice-feature["nice-feature"]
358+
style nice-feature fill:#ffffff,stroke:#ffffff
359+
360+
commitX(["commitX"])
361+
commit1(["commit1"])
362+
commit2(["commit2"])
363+
commitY(["commitY"])
364+
commit3(["commit3"])
365+
commit4(["commit4"])
366+
commit4Y(["New merge commit"])
367+
368+
master -.-> commit4
369+
commit4 --> commit3
370+
commit4 --> commit4Y
371+
cool-feature -.-> commitY
372+
commit3 --> commit2
373+
commit2 --> commit1
374+
commitY --> commitX
375+
commitY --> commit4Y
376+
commitX --> commit1
377+
```
378+
379+
After FF merge:
380+
381+
```mermaid
382+
graph LR
383+
384+
master["master"]
385+
style master fill:#ffffff,stroke:#ffffff
386+
cool-feature["cool-feature"]
387+
style cool-feature fill:#ffffff,stroke:#ffffff
388+
389+
commitX(["commitX"])
390+
commit1(["commit1"])
391+
commit2(["commit2"])
392+
commitY(["commitY"])
393+
commit3(["commit3"])
394+
commit4(["commit4"])
395+
commit4Y(["New merge commit"])
396+
397+
master -.-> commit4
398+
commit4 --> commit3
399+
commit4 --> commit4Y
400+
cool-feature -.-> commitY
401+
commit3 --> commit2
402+
commit2 --> commit1
403+
commitY --> commitX
404+
commitY --> commit4Y
405+
commitX --> commit1
406+
```
407+
338408
## Switching with uncommitted changes
339409

340410
As mentioned above, you switch between branches with:

0 commit comments

Comments
 (0)