Branches · lesson 7 of 7
Commands and ideas in this lesson
Agit switchfrom lesson 3.2
Bgit mergefrom lesson 3.3
CConflictsfrom lesson 3.4
Dgit tag -afrom lesson 3.6

Kusina: a dessert section

Last updated

Ana started a desserts branch last week. Since then Joaquin has changed the README on main. Your job: finish the dessert section on its branch, bring it into main, settle the conflict that's waiting, and tag the result v1.0 for Lola Remy's birthday.

By the end of this lesson you can

  • Build a piece of work on a branch in several commits
  • Merge it into main and settle a conflict
  • Mark the result with an annotated tag

The brief

You're Ana, in kusina, on the desserts branch. Since you made it, Joaquin committed "Explain the file layout in the README" on main.

  1. On desserts, add three dessert recipes (turon, halo-halo, ube halaya, or your own family's), each in its own commit. Use edit to write them.
  2. Also on desserts, change the README's line that starts "Each recipe is" so it mentions the desserts. (Joaquin changed that same line on main. That's the planted conflict.)
  3. Switch to main and merge desserts. Settle the conflict so the line keeps both Joaquin's explanation and yours.
  4. Tag the merge v1.0 with an annotated tag.

Use git status and git log --oneline --graph --all as often as you like.

Build it

Git sandbox
  1. On desserts, three new commits that each add a recipe
  2. A commit on desserts that changes the README
  3. On main, desserts merged in with a merge commit
  4. The conflict settled: no markers, merge finished
  5. The README keeps Joaquin’s line about build_index.py
  6. An annotated tag v1.0
  7. Every message is a short command that says what changed

Working folder

no changes

Staging area

nothing staged

Repository

10 commits on desserts

You are in ~/kusina on desserts, a branch Ana made last week. Joaquin has committed to main since.

Commit graph

  1. 78ba41d main Explain the file layout in the README
  2. 67e435d HEAD →desserts Cover the leche flan with foil
  3. ba04ca2 Add lumpiang shanghai recipe
  4. 98a5edc Add a script that builds the index page
  5. d078487 Make the sinigang steps clearer
  6. 145dc1e Add pancit bihon recipe
  7. 52d1f4d Say how much salt goes in the adobo
  8. 1c17fad Add a README
  9. 9c53888 Add leche flan recipe
  10. 1f359a2 Add sinigang recipe
  11. 601c654 Add adobo recipe

Spot the trap: markers carried along

Spot the trapAna

Ana merges main into desserts instead, to test there first. A conflict comes up; she settles half of it, runs git add . and git commit, then merges desserts into main. It goes through as a fast-forward.

What happens if…

Check your history

Run git log --oneline --graph. You should see the desserts commits on one line and Joaquin's README commit on the other, joining at your merge commit, with tag: v1.0 beside it.

Why did the merge into main make a merge commit, not a fast-forward?
Where should the v1.0 tag go?

Sources

Every command on this page behaves as these pages describe, and the sandbox prints what Git 2.55 prints. Hosting features (pull requests, protected branches) come from the host’s own documentation.

All sources for Simple Git