Hygiene and workflow
Gitflow
5 min read
Gitflow organizes work into two permanent branches, the production one (main) and the
development one (develop), and three types of work branch:
- feature: starts from
developand goes back to it; - release: starts from
developand finishes with a merge intomain, a version tag and a merge back intodevelop; - hotfix: starts from
mainand finishes like the release.
Versora implements Gitflow directly on top of git, without needing the git flow extension
installed. The configuration lives in the same gitflow.* keys as the extension, so a repository
initialized by another tool is recognized by Versora, and vice versa.
There are two ways to use Gitflow in Versora:
- through the GITFLOW section of the left panel, described on this page;
- as the Gitflow preset of the workflow, which adds
the bugfix type, the workflow health warnings and
the WORKFLOW section in place of GITFLOW. The
gitflow.*keys remain the source of the names and prefixes.
- GITFLOW section: "Gitflow isn't initialized in this repository." › Initialize Gitflow (disabled while the repository has no commits).
- GITFLOW section already initialized: the Configure Gitflow button in the header.
- Palette (Ctrl+P): "Gitflow: initialize…" or, if already initialized, "Gitflow: configure…".
-
Open Initialize Gitflow. The window explains: "Sets the branches and prefixes of the flow. The development branch is created if it doesn't exist yet."
-
Fill in the fields (the defaults come already filled in):
Field Default Production branch mainormaster, whichever exists (otherwise, the current branch)Development branch developPrefix for feature branches feature/Prefix for release branches release/Prefix for hotfix branches hotfix/Version tag prefix (optional) empty (e.g. v) -
Click Initialize (or Save, when configuring). The bar shows "Configuring Gitflow…" and the notice "Gitflow configured".
# creates develop if it doesn't exist yet: from origin/develop, if there is one; otherwise, from main
git branch develop origin/develop
git config --local gitflow.branch.master main
git config --local gitflow.branch.develop develop
git config --local gitflow.prefix.feature feature/
git config --local gitflow.prefix.release release/
git config --local gitflow.prefix.hotfix hotfix/
git config --local gitflow.prefix.versiontag v
Initialization doesn't go into Ctrl+Z. To change the values, use Configure
Gitflow. The created develop branch can be deleted like any other.
- "Enter different branches for production and development."
- "Branch "main" doesn't exist. Create the first commit before starting Gitflow."
- GITFLOW section: Start on the type's row ("Start feature (feature/…)").
- Palette (Ctrl+P): "Gitflow: start Feature…", "Gitflow: start Release…", "Gitflow: start Hotfix…". Without Gitflow, they're unavailable with the reason "Gitflow isn't set up in this repository".
- Click Start on the Feature row. The window says: "Creates a feature/… branch from develop and checks it out."
- Type the Feature name (e.g.
login-social). Spaces become hyphens.- For release and hotfix, the field is Version (e.g.
1.4.0) and comes already suggested from the commits since the last version tag: the release follows the automatic calculation of New version; the hotfix bumps the patch.
- For release and hotfix, the field is Version (e.g.
- Click Start. The bar shows "Starting feature/login-social…".
git checkout -b feature/login-social develop # release: from develop
git checkout -b hotfix/1.3.1 main # hotfix: from the production branch
Ctrl+Z undoes it ("Start feature/login-social"): the created branch goes away and the checkout goes back to the previous branch.
- GITFLOW section: Finish on the branch's row ("Finish feature/login-social").
- Menu: right-click the branch › Gitflow: finish feature… (the type changes). With a workflow chosen, this item gives way to the workflow's Finish.
- Palette (Ctrl+P): "Gitflow: finish feature/login-social…" (for the current branch).
- Open Finish feature. The window describes the steps:
- feature: "Merges feature/login-social into develop. Nothing is pushed to the remote automatically.";
- release and hotfix: "Merges release/1.4.0 into main, creates tag v1.4.0 and merges back into develop. Nothing is pushed to the remote automatically."
- Leave Delete local branch feature/login-social when done checked (default) or uncheck it to keep the branch.
- On a checked-out release or hotfix, check, if you want, First, update the version and CHANGELOG (New version…). See Version and changelog before finishing.
- Click Finish. The bar shows "Finishing feature/login-social…" and the notice sums it up, for example "release/1.4.0: merged into main, tag v1.4.0 created, merged into develop, branch deleted".
- Push
main,developand the tag whenever you want: nothing is pushed automatically.
# feature
git checkout develop --
git merge --no-ff --no-edit feature/login-social
git branch -d feature/login-social
# release and hotfix
git checkout main --
git merge --no-ff --no-edit release/1.4.0
git tag -a v1.4.0 -m "release 1.4.0" # only if the tag doesn't exist yet
git checkout develop --
git merge --no-ff --no-edit release/1.4.0
git branch -d release/1.4.0
The tag is the version tag prefix plus the branch name without the type prefix.
Ctrl+Z undoes the whole finish ("Finish release/1.4.0"): the merges, the tag and the branch deletion.
The operation stops at the merge that conflicted. Resolve it in the conflict editor, conclude the merge and finish again: the steps already done are skipped.
- ""feature-login" isn't a feature branch (feature/…).": the name doesn't start with the type's prefix.
- "Gitflow hasn't been initialized in this repository yet.": initialize it first.
On a checked-out release or hotfix, the First, update the version and CHANGELOG (New version…) box opens New version in Gitflow mode, before the merge:
- the title is "Version and changelog before finishing";
- the version already comes from the branch name (
release/1.4.0→1.4.0); - tag creation is disabled, with the note "— Gitflow creates the tag when finishing the release" (on a hotfix, "— Gitflow creates the tag when finishing the hotfix"), and there's no push;
- the button is Record 1.4.0 and finish: Versora creates the version and changelog commit on the release branch and then finishes.
If you close New version without confirming, the finish is canceled: "Finish canceled: the version wasn't recorded."
With Gitflow configured, other parts of Versora use develop as the reference:
- Branch cleanup and the
Branches review compare with
developon the automatic base, and arelease/*orhotfix/*that hasn't reachedmainyet is never offered for cleanup; - the Fork point uses
developas the origin; - conflict prediction compares with
developon the automatic target; - the issues' "Start work" uses Gitflow's feature prefix.
Gitflow has no page of its own in Preferences: everything lives in the gitflow.* keys of the
repository's local config. The workflow's Gitflow preset uses the Preferences › Workflow page.