Tags & tidy history
Mark releases forever, and clean up your commits before you share them.
1 Learn the idea
Two finishing touches. Tags give a permanent name to an important commit ("this is version 1.0"). Tidying turns a messy trail of "WIP" and "fix typo" commits into one clear commit before anyone else sees it.
Tags
git tag v1.0pins the namev1.0on the current commit. It never moves when you commit later.- Tags are not pushed automatically:
git push origin v1.0(one tag) orgit push --tags(all).
Tidying your own commits
git commit --amendreplaces the last commit with a new one — fix the message, or add a forgotten file.git reset --soft HEAD~3moves the branch back 3 commits but keeps all their changes staged. Onegit committhen makes a single clean commit.- In real git,
git rebase -i HEAD~3does the same interactively (squash, reorder, reword) in an editor. This simulator has no editor, so we use the reset trick — same result.
2 Watch it happen
Press Play or use → to step through. Watch the graph as each command runs.
Read this demo as text
$ git tag v1.0
We ship!
v1.0is pinned to this commit — atag: v1.0label in the graph.$ edit app.js "app v2 with search" $ git commit -am "Add serach"
New work… and a typo in the message. Note how
mainmoved forward, butv1.0stayed put. That is the difference between branch and tag.$ git commit --amend -m "Add search"
--amendreplaces the last commit. The old one is not edited — a new commit is made, and the faded one is left behind.$ edit app.js "app v2 with search + filter (WIP)" $ git commit -am "WIP"
Now a typical real-life trail of small commits…
$ edit app.js "app v2 with search + filter" $ git commit -am "fix typo"
…"fix typo"…
$ edit app.js "app v2 with search + filters, tested" $ git commit -am "really works now"
…"really works now". Nobody wants to read this history later.
$ git reset --soft HEAD~3
reset --soft HEAD~3movesmainback three commits. The changes are all still staged — nothing is lost.$ git commit -m "Add search filters"
One commit with one clear message replaces the three messy ones. The old commits fade out.
$ git tag v1.1 $ git push $ git push --tags
Tag the new release, push the branch, then push the tags (they are never sent automatically).
$ git log --oneline
A clean, readable history: every commit tells a story, releases are marked.
- Moves forward with every commit
- Where you work
- Pushed with
git push
- Never moves
- Marks a release or milestone
- Pushed with
git push origin <tag>/--tags
git tag v1.0Pin a permanent name to the current commitgit push origin v1.0 / --tagsPublish one tag / all tagsgit commit --amendReplace the last commit (message or content)git reset --soft HEAD~NUndo N commits, keep changes staged → squash3 Check your understanding
In this graph, you make another commit on main. What happens to the labels?
You created tag v2.0 and ran git push. Is the tag on the remote?
You have 4 local, unpushed commits ("WIP", "wip 2", "fix", "done"). How do you turn them into one commit in this simulator?
You pushed a commit, then ran git commit --amend. What happens on your next git push?
4 Practice for real
Clean up and release
Your 3 local commits are a mess. Squash them into a single commit with the message Add profile page (so history is: "Add profile page" → "Initial app"), tag it v2.0, and push both main and the tag to origin.