Git without fear · Chapter 24 of 28
Tags and releases
By the end of this chapter you can mark a release with a tag that never moves, push it to GitHub, and fix a tag that went on the wrong commit. Build it in your browser: a real editor and terminal, AI that explains, and tests that tell you when it works.
- Part: Teamwork
- 4 tasks
- Git
- In the all labs plan
The first 2 chapters of Git without fear are free. This one comes with the all labs plan.
Why you need this
The October menu is live, and Meera wants it marked: "When something breaks in November, I want to know exactly what we shipped." Bunty has already tried. He meant to mark the staff tasting beta as v0.9, typed git tag v0.9 on whatever he was on, which was this morning's Diwali work, and pushed it to GitHub.
A branch will not do for a release: main moves with every commit, so in November it points somewhere else. Writing the hash on a sticky note does not travel with the repository. And a plain git push does not send tags at all, so a tag made only on your laptop never reaches GitHub.
What you build: 4 tasks
Each task has tests. You write the code in the lab's editor and press Check.
- Task 1
Tag the release commit as v1.0
Put the tag v1.0 on the release commit, so anyone can find this release later.
1. Show the history with the tags next to the commits.
2. Find the commit "Release the October menu". It is one below the latest commit on main.
3. Make the tag v1.0 on that commit, not on the Diwali commit at the top. Make it annotated now, with a message (see task 4).
To pass: your tag v1.0 points at the commit "Release the October menu".
- Task 2
Push v1.0 to GitHub
A normal push sends branches only, so GitHub does not have v1.0 yet.
1. Push to origin and name the tag v1.0 in the push.
2. List the tags that GitHub has. v1.0 should be there.
To pass: GitHub (origin) has the tag v1.0, on the commit "Release the October menu".
- Task 3
Move Bunty's v0.9 to the staff beta commit, here and on GitHub
Bunty put v0.9 on the wrong commit and pushed it. Move it, here and on GitHub.
1. Delete your v0.9. Git will not make a tag with a name that already exists.
2. Make v0.9 again on the commit "Beta: the new menu for the staff tasting". It is three below the latest commit. A lightweight tag is fine.
3. Delete v0.9 on GitHub. GitHub does not replace a tag that it already has.
4. Push your new v0.9 to GitHub.
To pass: v0.9 points at "Beta: the new menu for the staff tasting", both in your repository and on GitHub.
- Task 4 · interview question
Interview: make v1.0 an annotated tag, not a lightweight one
Interview question: what is the difference between a lightweight tag and an annotated tag?
1. Make v1.0 an annotated tag, with the annotate option and a message.
2. Show v1.0. An annotated tag prints its tagger and message before the commit.
3. If your v1.0 is lightweight, delete it here and on GitHub. Then make it again and push it.
To pass: v1.0 is an annotated tag with a message, both in your repository and on GitHub, and it is still on "Release the October menu".
What you will learn
- A tag: a name for one commit that, unlike a branch, never moves.
- Lightweight and annotated tags: just a name, or a name with a tagger, a date and a message.
- Pushing tags: by name, because git push sends only branches.
- Moving a tag: delete it and make it again, here and on GitHub.
More in Teamwork
Build "Tags and releases" yourself
Your first week on Tapri’s team, and every Git situation it throws at you. A real editor and terminal in your browser, AI that explains, and a Check that says when it works.
The first 2 chapters of Git without fear are free. This one comes with the all labs plan.