Skip to content

GeneralGit from scratch

9. Workflows and tags

Guide · git, version control · updated on 19/08/2026

Author: Ángel Fernández Caravaca
Date: August 19, 2026

Every chapter so far has answered a question about what Git can do, and by now the list is fairly complete: commit, branch, merge, resolve, sync, propose, rewrite. None has answered the question teams actually argue about, which is which branches should exist and what each one is for. In this chapter we will look at the two families of answers people tend to converge on, that is, Git Flow and trunk-based development, how to choose between them honestly, and the command that marks a specific commit as the version that reached users.

What a workflow is

A workflow is a convention, that is, an agreement about how the commands from the previous chapters are used, and this is the first thing to be clear about. Git has no notion of a workflow, no command enforces one and nothing in .git records which one you follow. A branch called develop is a branch like any other, and Git will neither reward nor punish you for having it.

What a workflow answers is a short list of questions a team must agree on if it is going to work in parallel without treading on each other's toes:

  • Which branches are long-lived, that is, which names exist permanently and not just for the duration of a task.
  • Where you branch from when you start a piece of work.
  • Where the work is merged when it is finished.
  • What is on main at any given moment, that is, the last thing released or the next thing to be released.
  • How a release is made, that is, what turns a commit into a version users receive.

Every workflow you will read about is a different set of answers to those five questions, and the ones below are worth knowing not because you have to adopt them to the letter, but because they are the vocabulary teams use when they discuss the subject.

Note

The only part of a workflow Git can enforce is what Chapter 7 called protected branches, and even that lives on GitHub rather than in Git. Everything else holds up because people agreed on it, which is why the useful question about a workflow is not whether it is correct, but whether the team actually follows it.

Git Flow

Git Flow is the older and more elaborate of the two, described by Vincent Driessen in 2010, and it is built around the idea that the code being developed and the code being released are different things and deserve different branches. It defines five kinds of branch, two permanent and three temporary:

Branch Lifetime What it contains Created from Merged into
main Permanent Exactly what is in production, one commit per release — —
develop Permanent The next release while it is being built main, once —
feature/* Temporary A new piece of work develop develop
release/* Temporary A version being stabilised, that is, fixes only develop main and develop
hotfix/* Temporary An urgent fix for what is in production main main and develop

The two permanent branches are its heart. main is not where work happens, that is, it only receives a commit when a version is released, so its history is the list of the product's versions. develop is where work accumulates, so at any moment it contains everything that will go into the next release and nothing that has already been released.

A feature follows the cycle you already know from Chapters 3 and 4, with develop in the place main used to occupy:

1
2
3
4
5
6
7
git switch develop
git pull
git switch -c feature/user-export     # create the branch from develop
# ... commits ...
git switch develop
git merge --no-ff feature/user-export # merge, keeping the branch visible
git branch -d feature/user-export

The --no-ff from Chapter 4 is not decorative here, that is, it is part of the convention, since it keeps each feature identifiable as a unit in develop's graph.

When enough features have accumulated, a release branch is opened. From that moment develop is free to receive the features for the next version while the release branch only accepts fixes, which is the whole reason for the extra complexity:

1
2
3
4
5
6
7
8
git switch -c release/1.4.0 develop   # freeze what goes into 1.4.0
# ... only bug fixes, version-number bumps and changelog commits here ...
git switch main
git merge --no-ff release/1.4.0       # the release reaches production
git tag -a v1.4.0 -m "Release 1.4.0"  # mark it, as the second half of this chapter explains
git switch develop
git merge --no-ff release/1.4.0       # the fixes go back into development
git branch -d release/1.4.0

A hotfix has the same shape with the direction reversed, that is, it starts from main because what is broken is production, and it is also merged into both branches so the fix isn't lost in the next release:

1
2
3
4
git switch -c hotfix/1.4.1 main
# ... the fix ...
git switch main && git merge --no-ff hotfix/1.4.1 && git tag -a v1.4.1 -m "Hotfix 1.4.1"
git switch develop && git merge --no-ff hotfix/1.4.1

Important

Notice the pattern repeated in the last two blocks: everything merged into main must also be merged into develop. Forgetting the second merge is the classic Git Flow bug, and its symptom is a fix that works in production and reappears as a bug in the next version, because the branch the next version is built from never received it.

There is a helper tool that automates the branch names and the double merges, that is, git flow init, git flow feature start <name>, etc. There is no magic in it, that is, it runs exactly the commands above, and it is worth using only once you know how to do them by hand.

Tip

Git Flow is not obsolete, but it is often applied where it costs more than it gives. Its own author later added a note recommending it only for software that is versioned and shipped, e.g. a library, a desktop application, anything where users choose which version they run. If you deploy a web service several times a day, the ceremony of develop plus release branches gives you nothing.

Trunk-based development

The other family goes in the opposite direction and starts from a different premise: long-lived branches are the problem, not the solution. Every day a branch stays open is a day of divergence that will have to be reconciled, that is, the conflicts from Chapter 5, so the way to make integration painless is to integrate constantly.

The rules are short enough to state in full:

  • There is a single long-lived branch, that is, main, sometimes called the trunk.
  • main is always releasable, that is, it passes the tests and could be deployed at any moment.
  • Work is done on short-lived branches, measured in hours or a couple of days and merged through the pull request from Chapter 7.
  • Releases are made from main, by tagging a commit, and deployment is automated.

This is the GitHub Flow from Chapter 7 with the release question answered, and it is what most web services and open source projects on GitHub actually do. The whole cycle is the eight steps you have already learnt, plus a tag when a state of main goes to production.

Two mechanisms make it possible to keep main always releasable while unfinished work is merged into it, and they are worth knowing because they replace what develop used to do:

  • Feature flags, that is, the incomplete feature is merged but switched off in the configuration, so the code travels to production while staying invisible until it is switched on. This decouples merging from releasing, which is the real trick behind the whole model.
  • Release branches created only when needed, that is, main is tagged for a release, and a branch is only opened from that tag if a fix needs to be shipped for an old version. It is a hotfix branch created on demand instead of a permanent structure.

Warning

Trunk-based development is not "commit straight to main and cross your fingers". It only works when it is backed by the discipline it assumes, that is, small changes, a test suite that runs on every pull request and the branch protections from Chapter 7. Without that, "one branch, always releasable" degenerates into "one branch, often broken", which is worse than any amount of Git Flow ceremony.

Choosing between them

Side by side, the two models are answers to the five questions from the first section:

Git Flow Trunk-based
Long-lived branches main and develop Only main
Branch from develop main
What main contains The latest released version The latest integrated work
Branch lifetime Days or weeks Hours or days
Release Merge a release branch into main Tag a commit on main
Fits Versioned products, planned releases, several supported versions Web services, continuous deployment, open source
Main cost Ceremony and double merges Requires reliable tests and automation

The honest criterion is not the size of the team or its seniority, but whether your users choose which version they run. If they do, e.g. a library on PyPI or an application people install, then there are several live versions at once, the old ones need fixes, and you need the structure Git Flow provides. If they don't, e.g. a website where everyone is on whatever you last deployed, maintaining a develop branch is bookkeeping for a distinction that has no consequences.

Note

Most real teams sit somewhere in between and aren't embarrassed about it, e.g. trunk-based with a release branch that appears only at release time, or Git Flow without develop. The models are reference points for a discussion rather than standards to comply with, and a workflow everyone follows imperfectly is better than a stricter one half the team ignores.

For a personal project, that is, the situation this course was written for, the answer is easy: main plus short-lived branches, which is the trunk-based model without the automation. Anything more elaborate is structure for a coordination problem you don't have.

Tags: marking a commit permanently

Both models ended with the same command, so it is time to explain it. A tag is a name for a commit that never moves, and that last phrase is the whole idea. Compare it with the branch from Chapter 3:

Branch Tag
Where it lives .git/refs/heads/ .git/refs/tags/
What it points to A commit A commit
When you commit on it It moves forward It doesn't move, ever
What it means Work is happening here This exact state is significant

That really is the only difference, that is, both are a file containing a hash, and the tag is the one Git refuses to move forward. It gives you a permanent, readable name for a state of the project, which is what a version number is:

git tag -a v1.0.0 -m "First stable release"    # tag the current commit
git tag -a v0.9.0 a1b2c3d -m "Beta"            # tag an old commit, after the fact

Since a tag is a ref, it can be used anywhere a commit can be used, and that is where its practical value shows. Every command from Chapters 2, 4 and 6 accepts it:

1
2
3
4
git show v1.0.0                    # what that release contained
git diff v1.0.0 v1.1.0             # everything that changed between two versions
git log --oneline v1.0.0..v1.1.0   # the commits between them, that is, your changelog
git switch --detach v1.0.0         # go to that version to reproduce a bug

Important

Checking out a tag leaves you in the detached HEAD state from Chapter 2, and for the same reason as origin/main in Chapter 6: a tag is not a branch, so there is nothing for new commits to move forward. If you need to work from a released version, e.g. to fix it, create a branch from the tag with git switch -c hotfix/1.0.1 v1.0.0.

The two kinds of tag

Git has two, and the difference is not cosmetic:

git tag v1.0.0                              # lightweight
git tag -a v1.0.0 -m "First stable release" # annotated

A lightweight tag is nothing more than the file we described, that is, a name containing a hash, with no further information. An annotated tag is a full object stored in objects/, exactly like the commits from Chapter 1, and it records who created it, when and why:

git show v1.0.0
1
2
3
4
5
tag v1.0.0
Tagger: Ángel F. Caravaca <afdezcaravaca@gmail.com>
Date:   Tue Aug 11 18:20:00 2026 +0200

First stable release

Since it is an object, it can also be signed with the GPG key from Chapter 0, which is how a release proves it comes from you:

git tag -s v1.0.0 -m "First stable release"   # signed
git tag -v v1.0.0                             # verify the signature

The recommendation is simple and practically universal: use annotated tags for everything you release, and keep lightweight ones for private bookmarks, e.g. flagging a commit you want to find again this afternoon. A release is a piece of the project's history and deserves an author, a date and a message, and several tools, git describe among them, ignore lightweight tags by default.

Working with tags day to day

Listing, inspecting and deleting are nothing special:

1
2
3
4
5
git tag                            # every tag, in alphabetical order
git tag -l "v1.*"                  # only the ones matching a pattern
git tag -l --sort=-v:refname       # newest version first, sorted as versions rather than text
git tag -n                         # each tag with the first line of its message
git tag -d v1.0.0                  # delete it locally

The --sort=-v:refname deserves the space, since plain alphabetical order puts v1.10.0 before v1.9.0, which is wrong in exactly the one way that matters. The v: prefix tells Git to compare them as version numbers.

Then comes the one behaviour that surprises everyone, and it is this chapter's practical trap. git push doesn't push tags. You can tag a release, push, see everything go fine and find nothing on GitHub, because tags only travel when explicitly asked for:

1
2
3
git push origin v1.0.0        # push one tag
git push origin --tags        # push all of them
git push --follow-tags        # push the commits plus the annotated tags pointing to them

--follow-tags is the one worth adopting, since it publishes exactly the tags that belong to the commits you are pushing and ignores your private lightweight bookmarks. It can be made the default:

git config --global push.followTags true

Deleting a tag that has already been published takes two commands, that is, one per repository, and the second is easy to forget:

git tag -d v1.0.0                     # locally
git push origin --delete v1.0.0       # on the remote

Caution

A published tag should be treated as immutable, and for the reason from Chapter 8: other people have downloaded it, so moving it, that is, git tag -f, means their v1.0.0 and your v1.0.0 name different commits, and nothing will warn either of you. Build systems and package managers that resolved that tag once will silently disagree with the ones that resolve it later. If a release went wrong, publish v1.0.1; don't redefine v1.0.0.

One last command, which is the most underrated use of tags:

git describe --tags          # e.g. v1.4.0-12-gc3d4e5f

Read the answer as twelve commits after v1.4.0, at commit c3d4e5f. It turns any commit into a readable position relative to the last release, which is why build scripts use it to stamp a version on the artefact they produce.

From a tag to a release

A tag is a Git concept. A release is GitHub's layer on top of it, just as the pull request from Chapter 7 is GitHub's layer on top of a merge: a page tied to a tag, with release notes and, optionally, files to download, e.g. compiled binaries or packaged artefacts.

Creating one from the terminal:

1
2
3
4
gh release create v1.0.0 --title "1.0.0" --notes "First stable release"
gh release create v1.0.0 --generate-notes        # notes built from the merged pull requests
gh release create v1.0.0 ./dist/app.zip          # attaching a file
gh release list

--generate-notes is the handy one, since it composes the notes from the pull requests merged since the previous tag, which is exactly the changelog git log --oneline v0.9.0..v1.0.0 would have given you, written by the people who made the changes.

Tags are also the usual trigger for automation, that is, pushing a tag matching v* is what kicks off the pipeline that builds the artefacts, publishes the package and deploys. This is where the workflows from the first half of the chapter close the loop: whichever model you follow, the moment that turns work into a version is a tag, and everything that comes afterwards hangs off it.

Tip

Whatever you do with versions, agree on a scheme and write it down. The usual one is semantic versioning, that is, MAJOR.MINOR.PATCH, where MAJOR goes up when you break compatibility, MINOR when you add something without breaking anything and PATCH when you only fix bugs. The v prefix, that is, v1.4.0, is a convention and not part of the number, but it is the dominant one on GitHub and makes tags easy to filter with a pattern.

Summary

Command What it does
git switch -c feature/<name> develop Opens a feature branch in the Git Flow model
git merge --no-ff <branch> Merges while keeping the branch visible in the graph
git switch -c release/<version> develop Freezes what goes into a version, leaving develop free
git switch -c hotfix/<version> main Opens an urgent fix from what is in production
git tag Lists the tags
git tag -l "v1.*" Lists only the ones matching a pattern
git tag -l --sort=-v:refname Lists them sorted as versions, newest first
git tag -n Lists them with the first line of their message
git tag <name> Creates a lightweight tag, that is, a private bookmark
git tag -a <name> -m "<message>" Creates an annotated tag, that is, the one used for releases
git tag -a <name> <commit> Tags an old commit after the fact
git tag -s <name> -m "<message>" Creates a signed tag, using the GPG key from Chapter 0
git tag -v <name> Verifies a signed tag's signature
git tag -d <name> Deletes the tag locally
git push origin <tag> Publishes a tag
git push origin --tags Publishes every tag
git push --follow-tags Publishes the commits along with the annotated tags pointing to them
git push origin --delete <tag> Deletes a published tag on the remote
git show <tag> Shows what that version contained and who tagged it
git diff <tag1> <tag2> Everything that changed between two versions
git log --oneline <tag1>..<tag2> The commits between two versions, that is, a changelog
git switch --detach <tag> Takes you to a released version, with a detached HEAD
git describe --tags Names the current commit relative to the latest tag
gh release create <tag> --generate-notes Publishes a GitHub release with automatically generated notes

The picture is now complete in both directions. Downwards, we know what Git stores and how, that is, objects, refs and three areas. Upwards, we know how people organise themselves around it, that is, which branches exist, how work is proposed and reviewed, and how a commit becomes a version someone can install. Everything from here on is convenience rather than understanding, which is exactly what Chapter 10 is about: the VSCode extensions that put the graph, blame, diffs and pull requests where you are already working, so that the commands from the nine previous chapters are something you type when you want to and not because there is no other way.