📋

Gitflow 実践ガイド - フルサイクル開発者のための現場手順書

に公開

Gitflow 実践ガイド - フルサイクル開発者のための現場手順書

目次

  1. Gitflowの哲学と概要
  2. ブランチ戦略の詳細
  3. git-flow拡張ツールの活用
  4. 実践的ワークフロー
  5. よく使用するGitコマンド一覧
  6. シナリオ別対応方法
  7. トラブルシューティング
  8. チーム開発での運用方法
  9. CI/CDとの連携
  10. GitHubFlowとの比較

Gitflowの哲学と概要

基本哲学

  • 明確な責務分離: 各ブランチが明確な役割を持つ
  • 並行開発の支援: 複数機能の同時開発を効率的に管理
  • 安定性重視: 本番環境の安定性を最優先
  • 厳格なリリース管理: バージョン管理とリリースプロセスの標準化
  • 大規模チーム対応: 多数の開発者が同時に作業できる体制

Gitflowの特徴

  • 5つのブランチタイプ: main, develop, feature, release, hotfix
  • 明確なマージルール: どのブランチがどこにマージされるかが決まっている
  • タグベースのリリース: 各リリースにバージョンタグを付与
  • 長期ブランチの管理: mainとdevelopは永続的に存在

フロー図

ブランチ戦略の詳細

1. main ブランチ

目的: 本番環境用の安定版コード

特徴:

  • 常にプロダクション準備完了状態
  • 直接コミット禁止
  • releaseまたはhotfixブランチからのみマージ
  • 全コミットにバージョンタグが付与される

運用ルール:

# mainブランチは保護設定必須
- 直接プッシュ禁止
- Pull Request必須
- ステータスチェック必須
- 管理者のレビュー必須

2. develop ブランチ

目的: 開発統合ブランチ

特徴:

  • 次回リリース向けの最新開発コード
  • featureブランチのマージ先
  • releaseブランチの分岐元
  • CI/CDによる自動テスト実行

運用ルール:

# developブランチの管理
- featureブランチからのマージのみ
- 常にビルド可能な状態を保持
- 自動テストが全てパス
- 夜間にステージング環境へ自動デプロイ

3. feature ブランチ

目的: 新機能・改善の開発

特徴:

  • developから分岐
  • 開発完了後にdevelopにマージ
  • 削除される一時的なブランチ
  • 開発者が自由にコミット可能

命名規則:

feature/機能名
feature/issue-番号
feature/ユーザーストーリー

例:
feature/user-authentication
feature/payment-gateway
feature/responsive-design
feature/issue-1234
feature/oauth-integration

4. release ブランチ

目的: リリース準備とバグ修正

特徴:

  • developから分岐
  • mainとdevelopの両方にマージ
  • リリース準備専用(新機能追加禁止)
  • バージョン番号の更新

命名規則:

release/バージョン番号

例:
release/1.0.0
release/2.1.0
release/1.5.2

5. hotfix ブランチ

目的: 本番環境の緊急バグ修正

特徴:

  • mainから分岐
  • mainとdevelopの両方にマージ
  • 最優先で処理
  • パッチバージョンの更新

命名規則:

hotfix/バージョン番号
hotfix/修正内容

例:
hotfix/1.0.1
hotfix/security-fix
hotfix/payment-bug

git-flow拡張ツールの活用

インストール方法

macOS (Homebrew)

brew install git-flow-avh

Ubuntu/Debian

sudo apt-get install git-flow

Windows (Chocolatey)

choco install gitflow-avh

初期化と設定

プロジェクトでのgit-flow初期化

git flow init

# インタラクティブ設定
Branch name for production releases: [main] 
Branch name for "next release" development: [develop] 
Feature branches: [feature/] 
Bugfix branches: [bugfix/] 
Release branches: [release/] 
Hotfix branches: [hotfix/] 
Support branches: [support/] 
Version tag prefix: [v]

自動設定(推奨設定)

git flow init -d

# または手動設定
git config gitflow.branch.main main
git config gitflow.branch.develop develop
git config gitflow.prefix.feature feature/
git config gitflow.prefix.release release/
git config gitflow.prefix.hotfix hotfix/
git config gitflow.prefix.versiontag v

git-flowコマンド一覧

Feature開発

# 新しいfeatureブランチ開始
git flow feature start user-authentication

# feature開発完了(developにマージ)
git flow feature finish user-authentication

# featureブランチの公開
git flow feature publish user-authentication

# 公開されたfeatureブランチの取得
git flow feature pull origin user-authentication

Release管理

# リリースブランチ開始
git flow release start 1.0.0

# リリース完了(mainとdevelopにマージ、タグ作成)
git flow release finish 1.0.0

# リリースブランチの公開
git flow release publish 1.0.0

Hotfix対応

# hotfixブランチ開始
git flow hotfix start 1.0.1

# hotfix完了(mainとdevelopにマージ、タグ作成)
git flow hotfix finish 1.0.1

実践的ワークフロー

1. 新機能開発フロー(feature)

Step 1: 開発環境準備

# 最新のdevelopブランチに同期
git checkout develop
git pull origin develop

# 新しいfeatureブランチ開始
git flow feature start user-profile-management

# または手動作成
git checkout develop
git checkout -b feature/user-profile-management
git push -u origin feature/user-profile-management

Step 2: 開発作業

# 開発作業中の定期的なコミット
git add .
git commit -m "feat(profile): ユーザープロフィール表示機能の実装"

git add .
git commit -m "feat(profile): プロフィール編集フォームの追加"

git add .
git commit -m "test(profile): プロフィール機能のユニットテスト追加"

# リモートに定期的にプッシュ
git push origin feature/user-profile-management

Step 3: Feature完了とマージ

# git-flowを使用した場合
git flow feature finish user-profile-management

# 手動の場合
git checkout develop
git pull origin develop
git merge --no-ff feature/user-profile-management
git push origin develop
git branch -d feature/user-profile-management
git push origin --delete feature/user-profile-management

2. リリースフロー(release)

Step 1: リリース準備開始

# developが安定していることを確認
git checkout develop
git pull origin develop

# リリースブランチ開始
git flow release start 1.2.0

# または手動作成
git checkout develop
git checkout -b release/1.2.0

Step 2: リリース準備作業

# バージョン情報更新
echo "1.2.0" > VERSION
git add VERSION
git commit -m "chore(release): バージョンを1.2.0に更新"

# package.jsonのバージョン更新(Node.jsプロジェクトの場合)
npm version 1.2.0 --no-git-tag-version
git add package.json package-lock.json
git commit -m "chore(release): package.jsonのバージョンを1.2.0に更新"

# CHANGELOG.md更新
git add CHANGELOG.md
git commit -m "docs(release): v1.2.0のCHANGELOG追加"

# リリース関連のバグ修正
git add .
git commit -m "fix(release): リリース前のバグ修正"

Step 3: リリース完了

# git-flowを使用
git flow release finish 1.2.0

# 手動の場合
git checkout main
git merge --no-ff release/1.2.0
git tag -a v1.2.0 -m "Release version 1.2.0"
git checkout develop
git merge --no-ff release/1.2.0
git branch -d release/1.2.0

# リモートにプッシュ
git push origin main
git push origin develop
git push origin v1.2.0

3. 緊急修正フロー(hotfix)

Step 1: 緊急修正開始

# mainブランチから緊急修正開始
git checkout main
git pull origin main

git flow hotfix start 1.2.1

# または手動作成
git checkout main
git checkout -b hotfix/1.2.1

Step 2: 緊急修正作業

# 修正作業
git add .
git commit -m "fix(security): XSS脆弱性の緊急修正"

# テスト追加
git add .
git commit -m "test(security): XSS対策のテスト追加"

# バージョン更新
echo "1.2.1" > VERSION
git add VERSION
git commit -m "chore(hotfix): バージョンを1.2.1に更新"

Step 3: 緊急修正完了

# git-flowを使用
git flow hotfix finish 1.2.1

# 手動の場合
git checkout main
git merge --no-ff hotfix/1.2.1
git tag -a v1.2.1 -m "Hotfix version 1.2.1"
git checkout develop
git merge --no-ff hotfix/1.2.1
git branch -d hotfix/1.2.1

# リモートにプッシュ
git push origin main
git push origin develop
git push origin v1.2.1

よく使用するGitコマンド一覧

基本的なブランチ操作

# ブランチ一覧表示
git branch -a                          # 全ブランチ表示
git branch -r                          # リモートブランチ表示
git branch -v                          # 最後のコミット情報も表示

# ブランチ作成・切り替え
git checkout -b feature/new-feature     # ブランチ作成・切り替え
git switch -c feature/new-feature       # 新コマンド版
git push -u origin feature/new-feature  # リモートに初回プッシュ

# ブランチ削除
git branch -d feature/completed         # ローカルブランチ削除
git push origin --delete feature/old    # リモートブランチ削除

マージ操作

# マージ(マージコミット作成)
git merge --no-ff feature/my-feature    # 必ずマージコミットを作成

# スカッシュマージ
git merge --squash feature/my-feature   # コミットを1つにまとめてマージ
git commit -m "feat: 機能をまとめてマージ"

# リベース
git rebase develop                      # developブランチにリベース
git rebase -i HEAD~3                    # インタラクティブリベース

状態確認・履歴操作

# 状態確認
git status                              # 現在の状態
git log --oneline --graph --all         # グラフ形式でログ表示
git log --oneline --decorate --graph    # ブランチとタグも表示

# 差分確認
git diff                                # 作業ディレクトリとステージングの差分
git diff --staged                       # ステージングとHEADの差分
git diff develop..feature/my-feature    # ブランチ間の差分

# コミット履歴検索
git log --grep="fix"                    # コミットメッセージで検索
git log --author="username"             # 作成者で検索
git log --since="2 weeks ago"           # 期間指定

タグ操作

# タグ作成
git tag -a v1.0.0 -m "Release version 1.0.0"  # アノテートタグ作成
git tag v1.0.0                                 # 軽量タグ作成

# タグ表示
git tag                                         # タグ一覧
git tag -l "v1.*"                              # パターンでタグ検索
git show v1.0.0                               # タグ詳細表示

# タグ削除
git tag -d v1.0.0                             # ローカルタグ削除
git push origin --delete v1.0.0               # リモートタグ削除

# タグプッシュ
git push origin v1.0.0                        # 特定タグをプッシュ
git push origin --tags                        # 全タグをプッシュ

高度な操作

# stash操作
git stash                               # 現在の変更を一時保存
git stash list                          # stash一覧
git stash pop                           # 最新のstashを適用・削除
git stash apply stash@{1}               # 特定のstashを適用
git stash drop stash@{0}                # 特定のstashを削除

# 過去の状態に戻る
git reset --soft HEAD~1                 # 直前のコミットを取り消し(変更は保持)
git reset --hard HEAD~1                 # 直前のコミットを完全に取り消し
git revert <commit-hash>                # 特定コミットの変更を打ち消すコミット作成

# ファイル操作
git restore <file>                      # ファイルの変更を取り消し
git restore --staged <file>             # ステージングを取り消し
git clean -fd                           # 未追跡ファイルを削除

# リモート操作
git remote -v                           # リモート一覧
git fetch --all                         # 全リモートから取得
git pull --rebase origin develop        # リベースマージでプル

git-flow専用コマンド

# 初期化・設定
git flow init                           # git-flow初期化
git flow config                         # 設定確認

# Feature操作
git flow feature                        # feature一覧
git flow feature start <name>           # feature開始
git flow feature finish <name>          # feature完了
git flow feature publish <name>         # featureを公開
git flow feature pull origin <name>     # 公開されたfeatureを取得

# Release操作
git flow release                        # release一覧
git flow release start <version>        # release開始
git flow release finish <version>       # release完了
git flow release publish <version>      # releaseを公開

# Hotfix操作
git flow hotfix                         # hotfix一覧
git flow hotfix start <version>         # hotfix開始
git flow hotfix finish <version>        # hotfix完了

カスタムエイリアス設定

# 便利なエイリアスを設定
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.cm commit
git config --global alias.st status
git config --global alias.lg "log --oneline --graph --all"
git config --global alias.unstage "reset HEAD --"
git config --global alias.last "log -1 HEAD"

# Gitflow専用エイリアス
git config --global alias.fs "flow feature start"
git config --global alias.ff "flow feature finish"
git config --global alias.rs "flow release start"
git config --global alias.rf "flow release finish"
git config --global alias.hs "flow hotfix start"
git config --global alias.hf "flow hotfix finish"

シナリオ別対応方法

1. コンフリクト解決

Feature開発中のコンフリクト

# developの最新に追従
git checkout feature/my-feature
git fetch origin
git rebase origin/develop

# コンフリクトが発生した場合
# ファイルを編集してコンフリクト解決
git add <解決済みファイル>
git rebase --continue

# リベース完了後
git push --force-with-lease origin feature/my-feature

Release中のコンフリクト

# releaseブランチでのコンフリクト解決
git checkout release/1.0.0
# ファイル編集...
git add .
git commit -m "fix(release): マージコンフリクト解決"

# release完了時のコンフリクト
git flow release finish 1.0.0
# mainまたはdevelopでのコンフリクトが発生した場合、手動で解決

2. 間違った操作の修正

間違ったブランチにコミットした場合

# feature/wrongに間違ってコミットした内容をfeature/correctに移動
git checkout feature/wrong
git log --oneline -n 3  # コミットハッシュを確認

git checkout feature/correct
git cherry-pick <commit-hash>

git checkout feature/wrong
git reset --hard HEAD~1  # 間違ったコミットを削除

Release後にバグが発見された場合

# hotfixで対応
git flow hotfix start 1.0.1

# 修正作業
git add .
git commit -m "fix(hotfix): リリース後に発見されたバグの修正"

git flow hotfix finish 1.0.1

3. 長期間のFeature開発

定期的なdevelop同期

# feature開発中は定期的にdevelopの変更を取り込む
git checkout feature/long-term-feature
git fetch origin
git rebase origin/develop

# コンフリクトがある場合は解決
git push --force-with-lease origin feature/long-term-feature

Feature分割

# 大きなfeatureを分割する場合
git checkout feature/big-feature

# 完成した部分を別branchに切り出し
git checkout -b feature/part1
git reset --hard <特定のコミット>
git push -u origin feature/part1

# 元のbranchで不要な部分を削除
git checkout feature/big-feature
git rebase -i <ベースコミット>  # 完成した部分を削除

4. 緊急度別の対応フロー

レベル1: クリティカル(即座に対応)

# 本番停止レベルの障害
git flow hotfix start emergency-fix
# 最小限の修正
git add .
git commit -m "fix(emergency): 本番停止の緊急修正"
git flow hotfix finish emergency-fix
# 即座にデプロイ

レベル2: 高(当日中に対応)

# 機能に影響があるが本番は稼働
git flow hotfix start critical-bug
# しっかりテストして修正
git add .
git commit -m "fix(critical): 重要機能のバグ修正"
git flow hotfix finish critical-bug

レベル3: 中(次回リリースで対応)

# 軽微なバグや改善
git checkout develop
git checkout -b feature/bug-fix-minor
# 修正とテスト
git add .
git commit -m "fix(minor): 軽微なバグの修正"
# 通常のfeatureフローで対応

トラブルシューティング

よくある問題と解決方法

1. git-flowが正しく動作しない

# 設定確認
git flow config

# 再初期化
git flow init -f  # 強制的に再初期化

# 手動設定
git config gitflow.branch.main main
git config gitflow.branch.develop develop

2. "Updates were rejected" エラー

# リモートの変更を確認
git fetch origin

# rebaseして再プッシュ
git rebase origin/develop
git push --force-with-lease origin feature/my-feature

3. Release finish時のエラー

# 手動でrelease完了処理
git checkout main
git merge --no-ff release/1.0.0
git tag -a v1.0.0 -m "Release 1.0.0"

git checkout develop  
git merge --no-ff release/1.0.0

git branch -d release/1.0.0
git push origin main develop --tags

4. タグの重複エラー

# 既存タグを削除
git tag -d v1.0.0
git push origin --delete v1.0.0

# 新しいタグを作成
git tag -a v1.0.0 -m "Release 1.0.0"
git push origin v1.0.0

5. Hotfix中のdevelopマージエラー

# developが進んでいる場合
git checkout develop
git pull origin develop

# hotfixをマージ
git merge --no-ff hotfix/1.0.1

# コンフリクトがある場合は手動解決
git add .
git commit -m "merge: hotfix/1.0.1をdevelopに統合"

チーム開発での運用方法

1. チームルールの確立

ブランチ命名規則

# Feature branches
feature/機能名
feature/issue-番号
feature/JIRA-1234

# Release branches  
release/メジャー.マイナー.パッチ
release/1.2.0

# Hotfix branches
hotfix/バージョン
hotfix/1.2.1
hotfix/緊急修正内容

コミットメッセージ規約

# Conventional Commits形式
type(scope): subject

# 例
feat(auth): ユーザー認証機能の実装
fix(payment): 決済処理のバグ修正
docs(readme): セットアップ手順の更新
test(api): APIテストの追加
refactor(db): データベースアクセス層のリファクタリング

2. プルリクエスト運用

Feature PR テンプレート

## 概要
この機能の概要を記述

## 変更内容
- [ ] 機能A の実装
- [ ] 機能B の実装  
- [ ] テストの追加

## テスト
- [ ] 単体テスト追加
- [ ] 統合テスト確認
- [ ] 手動テスト完了

## 影響範囲
この変更が影響する範囲を記述

## レビューポイント
レビューで特に確認してほしい点

## 関連Issue
Closes #123
Related #456

Release PR テンプレート

## リリース概要
v1.2.0 リリース

## 新機能
- ユーザー認証機能
- 決済機能の改善

## バグ修正
- ログイン時のエラー修正
- レスポンシブデザインの調整

## 破壊的変更
- API v1の廃止

## テスト状況
- [ ] 全テストパス
- [ ] E2Eテスト完了
- [ ] パフォーマンステスト完了

## デプロイ計画
1. ステージング環境でのテスト
2. 本番環境への段階的デプロイ
3. ロールバック手順の確認

3. レビュープロセス

コードレビューチェックリスト

## 機能面
- [ ] 要件を満たしているか
- [ ] エッジケースが考慮されているか
- [ ] エラーハンドリングが適切か

## コード品質
- [ ] 可読性が高いか
- [ ] 適切なコメントがあるか
- [ ] DRY原則が守られているか
- [ ] SOLID原則に従っているか

## セキュリティ
- [ ] 入力値検証があるか
- [ ] 認証・認可が適切か
- [ ] 機密情報が露出していないか

## パフォーマンス
- [ ] N+1クエリがないか
- [ ] メモリリークの可能性はないか
- [ ] キャッシュが適切に使用されているか

## テスト
- [ ] 十分なテストカバレッジがあるか
- [ ] テストが意味のあるケースを網羅しているか

4. ブランチ保護設定

GitHub設定例

{
  "protection_rules": {
    "main": {
      "required_status_checks": {
        "strict": true,
        "contexts": ["ci/test", "ci/build", "ci/security-scan"]
      },
      "enforce_admins": true,
      "required_pull_request_reviews": {
        "required_approving_review_count": 2,
        "dismiss_stale_reviews": true,
        "require_code_owner_reviews": true
      },
      "restrictions": {
        "users": [],
        "teams": ["senior-developers", "tech-leads"]
      },
      "allow_force_pushes": false,
      "allow_deletions": false
    },
    "develop": {
      "required_status_checks": {
        "strict": true,
        "contexts": ["ci/test", "ci/build"]
      },
      "required_pull_request_reviews": {
        "required_approving_review_count": 1,
        "dismiss_stale_reviews": true
      },
      "allow_force_pushes": false
    }
  }
}

CI/CDとの連携

1. GitHub Actions設定

メインワークフロー

name: Gitflow CI/CD

on:
  push:
    branches: [main, develop, 'release/**', 'hotfix/**']
  pull_request:
    branches: [main, develop]

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [16.x, 18.x, 20.x]
    
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0  # Gitflowのため全履歴取得
    
    - name: Setup Node.js
      uses: actions/setup-node@v4
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'npm'
    
    - name: Install dependencies
      run: npm ci
    
    - name: Run linting
      run: npm run lint
    
    - name: Run type checking
      run: npm run type-check
    
    - name: Run unit tests
      run: npm run test:coverage
    
    - name: Run integration tests
      run: npm run test:integration
    
    - name: Upload coverage
      uses: codecov/codecov-action@v3

  build:
    needs: test
    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v4
    
    - name: Setup Node.js
      uses: actions/setup-node@v4
      with:
        node-version: '20.x'
        cache: 'npm'
    
    - name: Install dependencies
      run: npm ci
    
    - name: Build application
      run: npm run build
    
    - name: Upload build artifacts
      uses: actions/upload-artifact@v3
      with:
        name: build-${{ github.sha }}
        path: dist/

  deploy-staging:
    needs: [test, build]
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/develop'
    
    environment: staging
    
    steps:
    - name: Deploy to Staging
      run: |
        echo "Deploying to staging from develop branch"
        # ステージング環境へのデプロイスクリプト

  deploy-production:
    needs: [test, build]
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/main'
    
    environment: production
    
    steps:
    - name: Deploy to Production
      run: |
        echo "Deploying to production from main branch"
        # 本番環境へのデプロイスクリプト
    
    - name: Create GitHub Release
      if: startsWith(github.ref, 'refs/tags/')
      uses: actions/create-release@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        tag_name: ${{ github.ref_name }}
        release_name: Release ${{ github.ref_name }}
        body: |
          ## Changes in this release
          - 新機能追加
          - バグ修正
          - パフォーマンス改善
        draft: false
        prerelease: false

  security-scan:
    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v4
    
    - name: Run security audit
      run: npm audit --audit-level=moderate
    
    - name: Run Snyk vulnerability scan
      uses: snyk/actions/node@master
      env:
        SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}

Release専用ワークフロー

name: Release Process

on:
  push:
    branches: ['release/**']

jobs:
  release-checks:
    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v4
    
    - name: Extract version from branch
      id: version
      run: |
        VERSION=${GITHUB_REF#refs/heads/release/}
        echo "version=$VERSION" >> $GITHUB_OUTPUT
    
    - name: Validate version format
      run: |
        if [[ ! "${{ steps.version.outputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
          echo "Invalid version format: ${{ steps.version.outputs.version }}"
          exit 1
        fi
    
    - name: Check if version exists
      run: |
        if git tag | grep -q "^v${{ steps.version.outputs.version }}$"; then
          echo "Version v${{ steps.version.outputs.version }} already exists"
          exit 1
        fi
    
    - name: Run comprehensive tests
      run: |
        npm ci
        npm run test:all
        npm run e2e:all
    
    - name: Generate changelog
      run: |
        npx conventional-changelog -p angular -i CHANGELOG.md -s
        git add CHANGELOG.md
        git config user.name "GitHub Actions"
        git config user.email "actions@github.com"
        git commit -m "docs(release): update changelog for v${{ steps.version.outputs.version }}" || true
        git push origin HEAD:${{ github.ref_name }}

2. 自動バージョニング

package.jsonの自動更新

# npm version コマンドを使用
npm version patch --no-git-tag-version  # パッチバージョンアップ
npm version minor --no-git-tag-version  # マイナーバージョンアップ  
npm version major --no-git-tag-version  # メジャーバージョンアップ

# 手動更新スクリプト
#!/bin/bash
VERSION=$1
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
  echo "Invalid version format"
  exit 1
fi

# package.jsonの更新
npm version $VERSION --no-git-tag-version

# その他の設定ファイル更新
echo $VERSION > VERSION
sed -i "s/version = .*/version = \"$VERSION\"/" pyproject.toml

git add package.json package-lock.json VERSION pyproject.toml
git commit -m "chore(release): bump version to $VERSION"

GitHubFlowとの比較

適用場面の比較

項目 Gitflow GitHubFlow
チーム規模 大規模(5名以上) 小〜中規模(〜10名)
リリース頻度 定期リリース(週〜月単位) 継続的デプロイ(日単位)
品質要求 高い安定性が必要 迅速な改善を重視
複雑性 高い 低い
学習コスト 高い 低い
並行開発 多数の機能を並行開発 少数の機能を順次開発

ブランチ戦略の違い

Gitflow

main (本番)
├── develop (開発統合)
│   ├── feature/A (機能A)
│   ├── feature/B (機能B)
│   └── feature/C (機能C)
├── release/1.0.0 (リリース準備)
└── hotfix/1.0.1 (緊急修正)

GitHubFlow

main (本番)
├── feature/A (機能A)
├── feature/B (機能B)
└── feature/C (機能C)

使い分けの指針

Gitflowを選ぶべき場合

  • 厳格な品質管理が必要
  • 定期リリーススケジュールがある
  • 複数機能の並行開発が常態
  • 大規模チームでの開発
  • エンタープライズ向けシステム

GitHubFlowを選ぶべき場合

  • 迅速な開発を重視
  • 継続的デプロイを実践
  • 小規模チームでの開発
  • スタートアップアジャイル開発
  • Web アプリケーション

まとめ

Gitflowは複雑ですが、以下の利点があります:

主な利点

  1. 明確な責務分離: 各ブランチの役割が明確
  2. 並行開発支援: 複数機能の同時開発が効率的
  3. 品質保証: 段階的なテストとレビューで高品質を維持
  4. 安定したリリース: 計画的なリリースプロセス
  5. 緊急対応: hotfixによる迅速な問題解決

成功のポイント

  1. チーム全体での理解: 全員がワークフローを理解
  2. ツールの活用: git-flow拡張の積極的な利用
  3. 自動化: CI/CDによるプロセスの自動化
  4. 継続的改善: 定期的なプロセス見直し

運用のコツ

  • 小さなコミット: 頻繁で意味のあるコミット
  • 定期的な同期: developブランチとの定期的な同期
  • 早めのマージ: 長期間のブランチを避ける
  • コミュニケーション: チーム間の密な連携

Gitflowは習得に時間がかかりますが、大規模で品質を重視するプロジェクトでは非常に強力なワークフローです。チームの特性とプロジェクトの要求に合わせて、適切にカスタマイズして運用することが成功の鍵となります。

参考リンク

更新履歴

  • 2025-07-01: 初版作成
  • 2025-07-01: CI/CD連携セクション追加
  • 2025-07-01: トラブルシューティング拡充

Discussion