実践的なGitワークフロー
🔄 実践的なGitワークフロー
Section titled “🔄 実践的なGitワークフロー”実際の開発現場で使用される実践的なGitワークフローを詳しく解説します。
🚀 機能開発のワークフロー
Section titled “🚀 機能開発のワークフロー”📋 基本的な流れ
Section titled “📋 基本的な流れ”# 1. 最新のmainブランチを取得git checkout maingit pull origin main
# 2. featureブランチを作成git checkout -b feature/user-authentication
# 3. 開発作業git add .git commit -m "feat: ユーザー認証機能を実装"
# 4. 定期的にmainブランチの変更を取り込むgit checkout maingit pull origin maingit checkout feature/user-authenticationgit merge main# またはgit rebase main
# 5. リモートにプッシュgit push -u origin feature/user-authentication
# 6. プルリクエストを作成
# 7. レビューと承認
# 8. mainブランチにマージ
# 9. ローカルのmainブランチを更新git checkout maingit pull origin main
# 10. featureブランチを削除git branch -d feature/user-authenticationgit push origin --delete feature/user-authenticationバグ修正のワークフロー
Section titled “バグ修正のワークフロー”基本的な流れ
Section titled “基本的な流れ”# 1. バグを報告された# バグ: ログイン画面でエラーが発生
# 2. bugfixブランチを作成git checkout -b bugfix/login-error main
# 3. バグを修正git add .git commit -m "fix: ログイン画面のエラーを修正"
# 4. テストを実行npm test
# 5. リモートにプッシュgit push -u origin bugfix/login-error
# 6. プルリクエストを作成
# 7. レビューと承認
# 8. mainブランチにマージ
# 9. ローカルのmainブランチを更新git checkout maingit pull origin main
# 10. bugfixブランチを削除git branch -d bugfix/login-errorgit push origin --delete bugfix/login-errorホットフィックスのワークフロー
Section titled “ホットフィックスのワークフロー”基本的な流れ
Section titled “基本的な流れ”# 1. 緊急バグが報告された# バグ: セキュリティ脆弱性
# 2. hotfixブランチを作成(mainブランチから)git checkout -b hotfix/security-patch main
# 3. 緊急修正git add .git commit -m "hotfix: セキュリティパッチを適用"
# 4. テストを実行npm test
# 5. mainブランチにマージgit checkout maingit merge --no-ff hotfix/security-patchgit tag -a v1.0.1 -m "ホットフィックス v1.0.1"git push origin main --tags
# 6. developブランチにもマージgit checkout developgit merge --no-ff hotfix/security-patchgit push origin develop
# 7. hotfixブランチを削除git branch -d hotfix/security-patchgit push origin --delete hotfix/security-patchリリースのワークフロー
Section titled “リリースのワークフロー”基本的な流れ
Section titled “基本的な流れ”# 1. releaseブランチを作成git checkout -b release/v1.0.0 develop
# 2. バージョン番号を更新# package.json、CHANGELOG.mdなどを更新git add .git commit -m "chore: バージョン1.0.0の準備"git push -u origin release/v1.0.0
# 3. バグ修正などgit add .git commit -m "fix: リリース前のバグ修正"git push origin release/v1.0.0
# 4. ステージング環境でテスト
# 5. mainブランチにマージgit checkout maingit merge --no-ff release/v1.0.0git tag -a v1.0.0 -m "リリース v1.0.0"git push origin main --tags
# 6. developブランチにもマージgit checkout developgit merge --no-ff release/v1.0.0git push origin develop
# 7. releaseブランチを削除git branch -d release/v1.0.0git push origin --delete release/v1.0.0実践的なGitワークフローのポイント:
- 機能開発: featureブランチでの開発、定期的な同期、プルリクエスト
- バグ修正: bugfixブランチでの修正、テスト、プルリクエスト
- ホットフィックス: mainブランチからの分岐、緊急修正、両ブランチへのマージ
- リリース: releaseブランチでの準備、バージョン管理、タグ付け
適切なワークフローを実践することで、効率的で安全な開発ができます。