Git Flow
Git Flow is a workflow methodology that facilitates the organization and management of software development in collaborative projects. This methodology is based on the structured use of branches to manage different types of changes and versions of the software, providing a clear strategy for the development and release of functionalities, bug fixes and final versions.
Installing Git Flow
To use Git Flow, you must first install the tool. Depending on your operating system, you can follow the steps below:
-
Linux (Debian/Ubuntu):
sudo apt-get install git-flow
-
**macOS (using Homebrew):
brew install git-flow
-
Windows: You can use Git for Windows which includes support for Git Flow, or use tools like
scoop
:scoop install git-flow
Using Git Flow
Once the tool is installed, you can initialize Git Flow in your repository by running:
git flow init
This command will set up the basic branch structure (main
, develop
, etc.) and prompt you for some initial settings, such as the name of the branches.
Branches in Git Flow
Git Flow defines a set of branches with specific roles that help keep the project organized:
-
main
: This is the main branch that always contains the stable code ready to be released to production. It represents the current state of the software in production. -
develop
: This branch serves as the basis for development. It contains code that is in preparation for the next stable release. When it is decided to release a new version, thedevelop
branch is merged with themain
branch. -
**Feature branches (or
feature
) are used to develop new functionalities. These branches start fromdevelop
and, once completed, merge back todevelop
.-
Example with Git Flow: To create a new feature branch, you can use the following command:
git flow feature start nueva_funcionalidad
When the new functionality is ready, you can finalize it using:
git flow feature finish nueva_funcionalidad
This will merge the
feature
branch withdevelop
and delete it.
-
-
release branches (
release
) are created when the code indevelop
is ready to be released and a version needs to be prepared.-
Example with Git Flow: To create a release branch for version 1.0, we use:
git flow release start 1.0
After you have made the necessary adjustments and are ready to launch, you can finalize the launch branch with:
git flow release finish 1.0
This will merge the branch with
main
anddevelop
, and tag the version inmain
.
-
-
Hotfix: Hotfix branches are used to fix critical problems that occur in production.
-
Example with Git Flow: To create a quick fix branch, use:
git flow hotfix start correccion_critica
Once you have solved the problem, you can end the quick fix with:
git flow hotfix finish correccion_critica
This will merge the branch with
main
anddevelop
, and tag the version inmain
.
-
Workflow
- Initialize Git Flow: Set up the basic structure of the project with
git flow init
. - Development of new features: Feature branches are created to work on new features without affecting the code base.
- Release preparation: When the development is ready, a release branch (
release
) is created for testing and final adjustments before going into production. - Release to production: The
release
branch is merged withmain
and tagged with the corresponding version number. - Critical bug fixes: In case of urgent problems, a
hotfix
branch is created to fix them quickly and themain
anddevelop
branches are updated.
Git Flow provides a clear structure for software development, facilitating collaborative work, continuous integration and stable software delivery. This methodology is particularly useful in projects where it is necessary to maintain a clear release cycle and manage multiple releases in parallel.
For more information about Git Flow and how to implement it in your projects, you can consult the Git Flow reference sheet or explore tools such as git-flow, which automate branch management according to this methodology.