managing-git について
バージョン管理を共同で行う開発者向けの Git ワークフローガイドです。ブランチ、コミット、プルリクエストの進め方に加え、コマンドと確認項目をまとめています。
主な機能
- 01GitHub Flow と Git Flow
- 02Conventional Commits の規約
- 03ブランチ命名の指針
- 04プルリクエストの確認項目
- 05一般的な Git 操作と応用操作
活用シーン
- 01機能ブランチやリリースブランチの計画
- 02コミットメッセージと履歴の整理
- 03プルリクエストの作成とレビュー
- 04操作ミスからの復旧や回帰箇所の特定
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ cloudai-x/ claude-workflow-v2 --skill managing-gitインストール後、Claude Code で/managing-gitを入力して読み込まれたか確認します。
詳細
Git の管理
読み込むタイミング
- トリガー:ブランチ戦略、コミットのワークフロー、プルリクエスト、マージコンフリクト、バージョン管理に関する質問
- スキップ:Git 操作を伴わないタスク
機能開発のワークフロー
このチェックリストをコピーして、進捗を管理します。
Feature Development Progress:
- [ ] Step 1: Create feature branch from main
- [ ] Step 2: Make changes with atomic commits
- [ ] Step 3: Rebase on latest main
- [ ] Step 4: Push and create PR
- [ ] Step 5: Address review feedback
- [ ] Step 6: Merge after approval
ブランチ戦略
GitHub Flow(ほとんどのプロジェクトに推奨)
main ──●────●────●────●────●── (always deployable)
\ /
feature └──●──●──┘
mainは常にデプロイ可能な状態にしますmainから機能ブランチを作成します- PR +レビュー+マージを行います
- マージ後にデプロイします
Git Flow(リリースベースのプロジェクト向け)
main ──●─────────────●────── (releases only)
\ /
release └────●────┘
/
develop ──●──●────●──●──●──
\ /
feature └──●┘
コミット規約
Conventional Commits の形式
<type>(<scope>): <description>
[optional body]
[optional footer(s)]
種類
| 種類 | 説明 |
|---|---|
feat | 新機能 |
fix | バグ修正 |
docs | ドキュメントのみ |
style | フォーマット変更。ロジックの変更はありません |
refactor | バグ修正や機能追加を伴わないコード変更 |
perf | パフォーマンスの改善 |
test | テストの追加・更新 |
chore | ビルドプロセス、依存関係 |
ci | CI の設定 |
例
feat(auth): add OAuth2 login support
Implements Google and GitHub OAuth providers.
Closes #123
BREAKING CHANGE: Session tokens now expire after 24h
fix(api): handle null response from payment gateway
Previously caused 500 error when gateway returned null.
Now returns appropriate error message to user.
ブランチ名の付け方
<type>/<ticket-id>-<short-description>
# Examples
feature/AUTH-123-oauth-login
fix/BUG-456-null-pointer
chore/TECH-789-upgrade-deps
プルリクエストのワークフロー
PR を作成するときは、このチェックリストをコピーします。
PR Checklist:
- [ ] Code follows project conventions
- [ ] Tests added/updated for changes
- [ ] All tests pass locally
- [ ] No merge conflicts with main
- [ ] Documentation updated if needed
- [ ] No security vulnerabilities introduced
- [ ] PR description explains the "why"
PR テンプレート
## Summary
[Brief description of changes]
## Changes
- [Change 1]
- [Change 2]
## Testing
- [ ] Unit tests added/updated
- [ ] Manual testing performed
- [ ] E2E tests pass
## Screenshots (if UI changes)
[Before/After screenshots]
PR のサイズに関するガイドライン
| サイズ | 変更行数 | レビューの目安 |
|---|---|---|
| XS | < 50 | 簡単なレビュー |
| S | 50-200 | 通常のレビュー |
| M | 200-500 | 入念なレビュー |
| L | 500+ | 可能であれば分割 |
よく使う Git コマンド
日常のワークフロー
# Start new feature
git checkout main
git pull
git checkout -b feature/TICKET-123-description
# Commit changes
git add path/to/file # Stage specific files (git add -p needs an interactive terminal)
git commit -m "feat: description"
# Keep up with main
git fetch origin main
git rebase origin/main
# Push and create PR
git push -u origin HEAD # after rebasing an already-pushed branch: git push --force-with-lease
間違いの修正
# Amend last commit (before push)
git commit --amend
# Undo last commit (keep changes)
git reset --soft HEAD~1
# Undo last commit (discard changes)
git reset --hard HEAD~1 # also discards uncommitted changes
# Revert a pushed commit
git revert <commit-hash>
# Interactive rebase to clean up
git rebase -i HEAD~3
# Non-interactive: git commit --fixup=<sha>, then
GIT_SEQUENCE_EDITOR=: git rebase -i --autosquash HEAD~3
高度な操作
# Cherry-pick specific commit
git cherry-pick <commit-hash>
# Find which commit broke something
git bisect start
git bisect bad HEAD
git bisect good <known-good-commit>
# Stash with message
git stash push -m "WIP: feature description"
git stash list
git stash pop
コミットの検証
プッシュする前に、コミットを検証します。
Commit Validation:
- [ ] Each commit has a clear, descriptive message
- [ ] Commit type matches the change (feat, fix, etc.)
- [ ] No WIP or temporary commits
- [ ] No secrets or credentials committed
- [ ] Changes are atomic (one logical change per commit)
検証に失敗した場合は、プッシュする前に git rebase -i を使ってコミット履歴を整理します(対話型ターミナルを使用できない場合は、--fixup + --autosquash を使います)。
コメント
Markdown 対応