Skip to content

FAQ: Release Engineers: Performing a release with git flow

Ulrond edited this page Dec 16, 2024 · 4 revisions

Git Flow provides a structured branching model for managing software releases. Here's how you can use it to create a fixed tag release:

Start a Release Branch

  • Use git flow release start <release-name> (e.g., git flow release start 1.2.0)
  • This creates a new branch (e.g., release/1.2.0) from the develop branch.

Work on the Release

  • This branch is dedicated to finalizing the release, fixing bugs, and preparing release notes.
  • Do not add new features here; those should be targeted to develop for the next release.

Finish the Release

  • When the release is ready, use git flow release finish <release-name>, (note:<release-name is optional)
  • This performs several actions:
    • Merges release/1.2.0 into main
    • Tags the main commit with the release name (e.g., 1.2.0)
    • Merges release/1.2.0 back into develop to keep it up-to-date
    • Deletes the release/1.2.0 branch

Push Changes

  • Assuming your default remote is origin, and you're on main branch
    • Use git push --tags to push the tag and main branch to your remote repository.
    • Use git checkout develop to check out the develop branch
    • Use git push to push the develop branch

Example

# Start the release
git flow release start 1.2.0 

# Work on the release (fix bugs, update docs, etc.)
# ...

## Generate a change log see (https://github.com/cookpete/auto-changelog)
autochange-log -v 1.2.0
git add CHANGELOG.md
git commit -m "Bumped CHANGELOG.md for release"

# Finish the release
git flow release finish 1.2.0

# Code should be merged to both develop & main
# If successful & not merge errors the branch will be `develop`
# If merge errors, follow instructions and re-run etc.

# Merge has occurred to develop
git push  # pushes develop
git push --tags # pushes the tags
git checkout main # swaps branch to main
git push # pushes main

Benefits of Using Git Flow Release

  • Clear Structure: Provides a well-defined workflow for managing releases.
  • Dedicated Branch: The release branch isolates release-related work from ongoing development.
  • Version Tracking: Tags make it easy to identify and roll back to specific releases.
  • Automation: Git Flow commands automate the merging and tagging process.

Additional Tips

  • Hotfixes: Use git flow hotfix to quickly address critical issues in production releases.
  • Support Branches: Use git flow support to maintain older releases.

By following this approach, you can streamline your release process, ensure consistent versioning, and maintain a clean Git history.

Refer also to FAQ: Git-Flow: Developers Branching Model

Clone this wiki locally