Tidy and release
Last updated
Kusina is nearly ready for the family reunion, where Lola Remy wants printed copies. Ana has one more branch, and its history is a mess of “wip” and “oops”. In this lesson she tidies it before anyone sees it, the family agrees a commit convention, and Kusina gets its first release: v1.0.
By the end of this lesson you can
- Tidy an unshared branch with interactive rebase
- Rebase a branch onto the latest main before a pull request
- Write Conventional Commit messages
- Tag a release, push the tag, and write release notes from the history
A messy branch
In ~/ana-kusina, on an up-to-date main, Ana adds a desserts note to the README and a new recipe, the way people really work: in bits.
git switch -c reunion-extras (add a section to README.md: Desserts, for the reunion) git commit -am "wip" (add ube-halaya.md) git add ube-halaya.md git commit -m "ube" (fix a typo in ube-halaya.md) git commit -am "oops" (finish the README section) git commit -am "more readme" git log --oneline main.. 0b4c3d2 (HEAD -> reunion-extras) more readme 9a8b7c6 oops 5f4e3d2 ube 1a2b3c4 wip
For the recipe, use Lola Remy's ube halaya, or a dessert of your own family's.
Tidy it
Nobody has seen this branch, so rewriting it is safe (lesson 6.3). Aim for two commits: one for the recipe (with its typo fix folded in) and one for the README.
git rebase -i main
In the editor, reorder and change the lines (lesson 6.4):
pick 5f4e3d2 ube fixup 9a8b7c6 oops pick 1a2b3c4 wip squash 0b4c3d2 more readme
Save and close. Git stops for the squashed commit's message: write a good one. Then reword the recipe's message with git commit --amend once the rebase is done, or with reword in the todo list. The goal:
git log --oneline main.. d7e6f5a docs: add a desserts section to the README 3c2b1a0 feat: add ube halaya recipe
Catch up with main, and share
While Ana was tidying, Carla merged something. Rebase the branch onto the latest main so the pull request is a straight line on top:
git fetch git rebase origin/main Successfully rebased and updated refs/heads/reunion-extras. git push -u origin reunion-extras
(To make that happen in your practice, have Carla push one small fix to main first.) Open a pull request, have Carla approve it, and merge. Without a host: as Carla, review with git diff main...origin/reunion-extras; as Ana, merge into main and push.
Agree a convention
From now on Kusina uses Conventional Commits (lesson 7.2). Agree what each type means for a recipe book, and write it down where contributors will find it, at the end of the README:
## Commit messages We use Conventional Commits: - feat: a new recipe or section - fix: a correction to a recipe (an amount, a time, a step) - docs: changes to this README or other notes - chore: tidying that changes no recipe Example: fix: steam the leche flan for 45 minutes
Commit it with a message that follows it: docs: describe the commit message convention.
Tag v1.0
The printed edition comes from main as it is now. Tag it with an annotated tag (lesson 3.6), which records who tagged it, when and why, and push the tag: git push doesn't send tags by itself.
git switch main git pull git tag -a v1.0 -m "Kusina 1.0: the reunion edition" git push origin v1.0 ... * [new tag] v1.0 -> v1.0
Release notes
On a hosting site, make a release from the tag: a page with notes, where people can download that exact version. Git gives you the material for the notes:
git shortlog v1.0 Ana Reyes (24): Ignore editor files, secrets and media Add a README Add chicken adobo recipe ... Carla Reyes (4): Warn that strong vinegar needs less ...
Write notes for people, not machines: what's in this edition, who contributed, and anything to know. For the next release, git log --oneline v1.0.. lists exactly what's new since this one, and with Conventional Commits you can group it by feat and fix.
Check your release
git describe v1.0 git show v1.0 --no-patch tag v1.0 Tagger: Ana Reyes <[email protected]> Date: ... Kusina 1.0: the reunion edition commit 8f7e6d5... ... git ls-remote --tags origin ... refs/tags/v1.0 ... refs/tags/v1.0^{}
git describe prints the nearest tag: v1.0 exactly, while main is on the tagged commit; after another commit it prints something like v1.0-1-g1a2b3c4, one commit past v1.0.
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.
- Git documentation: git-rebase, interactive mode
- Conventional Commits 1.0.0
- Git documentation: git-tag
- Git documentation: git-shortlog
- GitHub Docs: About releases: a host's page for a tag, with notes and files