Version control and teamwork
Introducido
6:03
Ingeniería de software
Software engineering is how systems outlive their authors. The first three units shape the product: requirements, architecture and interface design. The next…
Narración en inglés · subtítulos en inglés y 中文 que puedes cambiar
En esta lección
| English | Significado |
|---|---|
| branching model/ˈbræntʃɪŋ ˈmɒdl/ | modelo de ramificación |
| pull request/pʊl rɪˈkwest/ | a request to merge one branch's changes into another, usually with review |
| merge conflict/mɜːdʒ ˈkɒnflɪkt/ | The tool telling you that two decisions collided. |
| Merge/mɜːdʒ/ | combining the histories of two branches |
| commit/kəˈmɪt/ | a saved snapshot of changes in version control |
| code review/kəʊd rɪˈvjuː/ | another developer reading changes before they are merged |
| Rebase/rɪˈbeɪs/ | moving a branch's commits so they start from a newer base commit |
| Semantic versioning/səˈmæntɪk ˈvɜːʃənɪŋ/ | MAJOR.MINOR.PATCH version numbers that signal breaking changes, new features and fixes |
| base/beɪs/ | the commit that a branch starts from |
El código principal siempre liberable
- El modelo de ramificación del repositorio del curso:
mainsiempre liberable, ramas de características de corta duración, solicitudes de fusión con revisión. Los conflictos de fusión son la máquina informando que dos decisiones chocaron.

In the course model, main is —
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
Short-lived branches merge back through reviewed pull requests.
Granularidad de los commits
- Un commit = un cambio defendible, vinculado a su requisito, pruebas verdes en cada commit. Bisect necesita esto: un historial ejecutable acota una regresión a un solo cambio en $\log_2 n$ revisiones — 12 commits significan como máximo 4.
- Los volcados de commits ("semana de trabajo") matan bisect; los commits de fusión sin mensaje pierden la decisión.
You have edited two files and want to record them as one commit on your feature branch. Which pair of commands does that?
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
git add stages the changed files; git commit records the staged changes as one commit with its message. Push only sends commits that already exist.
El conflicto y la revisión
- Dos ramas editan
LOAN_LIMIT(elevar a 6 vs extraer a config): la resolución es una decisión, registrada en el mensaje del commit de fusión. Los conflictos resueltos en silencio son decisiones perdidas. - El contrato de revisión: diff + pruebas + enlace al requisito, bajo ~200 líneas cambiadas; revisar contra la prueba de aceptación, no contra el gusto.
Bisect over 12 runnable commits needs at most —
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
log2(12) rounded up: 4 checkouts narrows the regression.
Esta tarjeta es nueva, por eso aparece en inglés hasta que su traducción esté lista.
The conflict and the review
- Two branches edit
LOAN_LIMIT: one raises it to 6, the other moves it to a config file. The resolution is a decision, and it belongs in the merge commit's message. A conflict resolved silently is a lost decision. - The code review 代码审查 contract: the diff, the tests and a link to the requirement, under about 200 changed lines. Review against the acceptance test, not against personal taste.
A conflict resolution belongs —
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
The resolution is a decision: record it where the code lives.
Esta tarjeta se corrigió, por eso aparece en inglés hasta que se actualice su traducción.
Merge, rebase and bisect
- Merge 合并 joins two histories and keeps both as they happened. Rebase 变基 replays your commits on top of
mainto give a straight line, but it rewrites them, so never rebase a branch that others have already pulled. git bisecthalves the range of suspects with each test: $100$ commits need at most $\lceil \log_2 100 \rceil = 7$ checkouts. Each tested commit must be usable with a test that distinguishes good from bad revisions.
A regression hides somewhere in 1000 commits. At most how many bisect checkouts find it?
Dificultad 2/5 · 140 monedas + un pequeño bono en el primer intento de hoy
2^10 = 1024 is at least 1000, so 10 halvings suffice.
Rebasing a branch that teammates have already pulled is safe.
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
Rebase rewrites the commits, so their copies no longer match and must be repaired by hand.
Esta tarjeta es nueva, por eso aparece en inglés hasta que su traducción esté lista.
Version numbers that mean something
- Semantic versioning 语义化版本 writes MAJOR.MINOR.PATCH. From 2.3.1, a bug fix gives 2.3.2, a new feature that keeps old code working gives 2.4.0, and a breaking change gives 3.0.0.
- The number is a promise: a library user can take any 2.x update safely, but must read the notes before moving to 3.0.
Version 2.3.1 gains a new, backward-compatible API call. The next version is:
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
A compatible feature bumps MINOR and resets PATCH.
Esta tarjeta es nueva, por eso aparece en inglés hasta que su traducción esté lista.
Worked example: the three-way merge
- Git compares both branches with their common base 基础版本. The base has
LOAN_LIMIT = 5; your branch makes it 6; their branch leaves that line alone and edits another file. Only one side changed the line, so git takes 6, with no conflict. - If their branch had changed it to 4, both sides would have changed the same line in different ways: a conflict. Git stops and marks the file:
<<<<<<< HEAD
LOAN_LIMIT = 6
=======
LOAN_LIMIT = 4
>>>>>>> their-branch
- A person decides: edit the file to the value you agree on, delete the three marker lines, then
git addand commit, saying why in the message. Most of what looks like "merge magic" is this one rule.
In a three-way merge, a line changed on only one branch causes a conflict.
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
Git takes the changed side; a conflict needs both sides to change it differently.
Most checkouts git bisect needs to find the bad commit among 1000?
Dificultad 2/5 · 140 monedas + un pequeño bono en el primer intento de hoy
$\lceil\log_2 1000\rceil = 10$.
Esta tarjeta es nueva, por eso aparece en inglés hasta que su traducción esté lista.
Marks that slip away
- Rebasing a shared branch. It rewrites commits 提交 that others have already pulled.
- Huge commits. A week of work in one commit leaves bisect nothing to narrow.
- Resolving a conflict silently. The resolution is a decision; record it in the merge message.
Esta tarjeta es nueva, por eso aparece en inglés hasta que su traducción esté lista.
Recap
mainstays releasable; feature branches are short-lived; pull requests get reviewed.- One commit is one change you can defend, linked to its requirement.
- A conflict resolution is a decision: record it in the merge message.
- Semantic versioning 语义化版本, starting from 2.3.1:
| Change | New version |
|---|---|
| Bug fix | 2.3.2 |
| New feature, old code still works | 2.4.0 |
| Breaking change | 3.0.0 |
¿Qué salió mal? Solo el equipo del sitio ve esta información.