Gitflow Workflow

What is Gitflow?

Gitflow is a branching model for Git that defines a strict branching strategy designed around the project release. It provides a robust framework for managing larger projects.

Branch Types

Main Branches

Supporting Branches

Workflow Overview

Feature Development

  1. Create a feature branch from develop
  2. Develop the feature
  3. Merge back to develop when complete

Release Preparation

  1. Create a release branch from develop
  2. Test and fix bugs
  3. Merge to main and tag the release
  4. Merge back to develop

Hotfix

  1. Create a hotfix branch from main
  2. Fix the issue
  3. Merge to main and tag
  4. Merge back to develop

Detailed Process

Starting a Feature

# Create feature branch
git checkout -b feature/new-feature develop

# Work on feature
git add .
git commit -m "feat: implement new feature"

# Merge back to develop
git checkout develop
git merge --no-ff feature/new-feature

# Delete feature branch
git branch -d feature/new-feature

Preparing a Release

# Create release branch
git checkout -b release/1.2.0 develop

# Final testing and bug fixes
git commit -m "fix: resolve issue in release"

# Merge to main
git checkout main
git merge --no-ff release/1.2.0

# Tag the release
git tag -a 1.2.0 -m "Release version 1.2.0"

# Merge back to develop
git checkout develop
git merge --no-ff release/1.2.0

# Delete release branch
git branch -d release/1.2.0

Hotfix Process

# Create hotfix branch
git checkout -b hotfix/1.2.1 main

# Fix the issue
git commit -m "fix: critical bug in production"

# Merge to main
git checkout main
git merge --no-ff hotfix/1.2.1

# Tag the hotfix
git tag -a 1.2.1 -m "Hotfix version 1.2.1"

# Merge to develop
git checkout develop
git merge --no-ff hotfix/1.2.1

# Delete hotfix branch
git branch -d hotfix/1.2.1

Branch Naming Conventions

Advantages

Disadvantages

When to Use Gitflow

Tools and Integration

Gitflow Extensions

# Install git-flow
brew install git-flow  # macOS
sudo apt install git-flow  # Ubuntu

# Initialize git-flow in repository
git flow init

# Create feature
git flow feature start new-feature

# Finish feature
git flow feature finish new-feature

GitHub/GitLab Integration

Alternatives

Best Practices

Common Issues

Long-Running Feature Branches

Release Branch Conflicts

Hotfix Complications

Remember: Gitflow is a framework, not a strict rule. Adapt it to your team's needs.

Loading