diff --git a/advanced/github-features-detailed.md b/advanced/github-features-detailed.md new file mode 100644 index 0000000..6a0d112 --- /dev/null +++ b/advanced/github-features-detailed.md @@ -0,0 +1,2005 @@ +--- +layout: default +title: "GitHub機能詳細ガイド - 全20機能の完全解説" +description: "GitHubの全機能を実例とベストプラクティスと共に徹底解説" +--- + +# 📚 GitHub機能詳細ガイド - 全20機能の完全解説 + +GitHubの全20機能について、実践的な使い方からプロレベルの活用法まで徹底的に解説します。 + +--- + +## 📋 目次 + +### 基本機能(1-6) +1. [リポジトリ(Repository)](#1-リポジトリrepository) +2. [ブランチ(Branch)](#2-ブランチbranch) +3. [コミット(Commit)](#3-コミットcommit) +4. [プルリクエスト(Pull Request)](#4-プルリクエストpull-request) +5. [イシュー(Issues)](#5-イシューissues) +6. [プロジェクト(Projects)](#6-プロジェクトprojects) + +### 自動化・公開機能(7-9) +7. [アクション(Actions)](#7-アクションactions) +8. [ページ(Pages)](#8-ページpages) +9. [ウィキ(Wiki)](#9-ウィキwiki) + +### ソーシャル機能(10-12) +10. [ウォッチ(Watch)](#10-ウォッチwatch) +11. [スター(Star)](#11-スターstar) +12. [フォーク(Fork)](#12-フォークfork) + +### Git操作機能(13-16) +13. [クローン(Clone)](#13-クローンclone) +14. [プッシュ(Push)](#14-プッシュpush) +15. [プル(Pull)](#15-プルpull) +16. [マージ(Merge)](#16-マージmerge) + +### 拡張機能(17-20) +17. [ディスカッション(Discussions)](#17-ディスカッションdiscussions) +18. [ギスト(Gist)](#18-ギストgist) +19. [パッケージ(Packages)](#19-パッケージpackages) +20. [スポンサー(Sponsors)](#20-スポンサーsponsors) + +--- + +## 1. 📁 リポジトリ(Repository) + +### 概要 +リポジトリは、プロジェクトの全ファイル、履歴、設定を保存する基本単位です。Googleドライブのフォルダに似ていますが、変更履歴を完全に記録し、複数人での同時編集を可能にします。 + +### 詳細機能 + +#### リポジトリの種類 +``` +┌─────────────────────────────────────────────┐ +│ リポジトリタイプ │ +├─────────────────┬───────────────────────────┤ +│ Public │ Private │ +├─────────────────┼───────────────────────────┤ +│ ✓ 誰でも閲覧可 │ ✓ 招待者のみ閲覧可 │ +│ ✓ 検索可能 │ ✗ 検索不可 │ +│ ✓ 無料・無制限 │ ✓ 無料(個人) │ +│ ✓ GitHub Pages │ ✓ Pro版でPages可 │ +└─────────────────┴───────────────────────────┘ +``` + +#### 必須ファイル構成 +``` +my-project/ +├── README.md # プロジェクト説明(必須) +├── LICENSE # ライセンス情報 +├── .gitignore # 無視ファイル設定 +├── .github/ # GitHub設定 +│ ├── workflows/ # Actions設定 +│ ├── ISSUE_TEMPLATE/ +│ ├── PULL_REQUEST_TEMPLATE.md +│ └── CODEOWNERS # コードオーナー +├── docs/ # ドキュメント +├── src/ # ソースコード +└── tests/ # テストコード +``` + +### 実践例 + +#### 1. テンプレートからリポジトリ作成 +```bash +# GitHub CLIを使用 +gh repo create my-app --template owner/template-repo --public + +# テンプレート使用の利点 +- 標準構成の即時適用 +- CI/CD設定の継承 +- コーディング規約の統一 +``` + +#### 2. モノレポ構成 +``` +company-monorepo/ +├── packages/ +│ ├── frontend/ # Reactアプリ +│ ├── backend/ # Node.js API +│ ├── mobile/ # React Native +│ └── shared/ # 共通ライブラリ +├── lerna.json # Lernaモノレポ設定 +└── package.json # ルート設定 +``` + +#### 3. リポジトリ設定のベストプラクティス +```yaml +# .github/settings.yml (probot/settings使用) +repository: + name: my-project + description: プロジェクトの説明 + private: false + has_issues: true + has_projects: true + has_wiki: true + has_downloads: true + default_branch: main + allow_squash_merge: true + allow_merge_commit: true + allow_rebase_merge: false + delete_branch_on_merge: true + enable_automated_security_fixes: true +``` + +### 高度な活用 + +#### 1. リポジトリインサイト分析 +``` +Insights → 各種分析 +├── Pulse: 週次/月次アクティビティ +├── Contributors: 貢献者統計 +├── Community: コミュニティ健全性 +├── Traffic: アクセス統計 +├── Commits: コミット頻度 +├── Code frequency: コード追加/削除 +└── Dependency graph: 依存関係 +``` + +#### 2. セキュリティ設定 +```yaml +# Security → Settings +- ✓ Dependency alerts +- ✓ Dependabot security updates +- ✓ Code scanning alerts +- ✓ Secret scanning alerts +``` + +#### 3. アクセス管理 +``` +Settings → Manage access +├── Collaborators: 個別招待 +├── Teams: チーム単位管理 +└── Deploy keys: CI/CD用鍵 +``` + +### トラブルシューティング + +#### リポジトリサイズ問題 +```bash +# 大きなファイルの履歴削除 +git filter-branch --force --index-filter \ + "git rm --cached --ignore-unmatch path/to/large-file" \ + --prune-empty --tag-name-filter cat -- --all + +# Git LFS導入 +git lfs track "*.psd" +git lfs track "*.zip" +git add .gitattributes +``` + +--- + +## 2. 🌿 ブランチ(Branch) + +### 概要 +ブランチは、メインのコードから分岐して独立した開発を行うための仕組みです。複数の機能を並行開発したり、実験的な変更を安全に試すことができます。 + +### ブランチ戦略 + +#### 1. Git Flow +``` +main (production) +│ +├── develop (開発統合) +│ ├── feature/user-auth +│ ├── feature/payment +│ └── feature/notifications +│ +├── release/v1.2.0 +│ └── 本番リリース準備 +│ +└── hotfix/critical-bug + └── 緊急修正 +``` + +#### 2. GitHub Flow(シンプル) +``` +main +├── feature/new-feature +├── fix/bug-123 +└── docs/update-readme +``` + +#### 3. GitLab Flow(環境別) +``` +main +├── pre-production +├── production +└── feature-branches +``` + +### 実践的なブランチ運用 + +#### ブランチ命名規則 +```bash +# 機能追加 +feature/user-authentication +feature/JIRA-123-shopping-cart + +# バグ修正 +fix/login-error +bugfix/issue-456 + +# ドキュメント +docs/api-documentation +docs/installation-guide + +# リファクタリング +refactor/database-optimization +chore/update-dependencies + +# リリース +release/v2.0.0 +release/2023-12-01 +``` + +#### ブランチ保護ルール +```yaml +# branch protection rules +main: + required_reviews: 2 + dismiss_stale_reviews: true + require_code_owner_reviews: true + required_status_checks: + - continuous-integration/travis-ci + - security/snyk + enforce_admins: false + restrictions: + users: [] + teams: ["maintainers"] +``` + +### 高度なブランチ操作 + +#### 1. ブランチの比較とマージ予測 +```bash +# ブランチ間の差分確認 +git diff main..feature/new-feature + +# マージ予測(ドライラン) +git merge --no-commit --no-ff feature/new-feature +git diff --cached +git merge --abort # 取り消し + +# コンフリクト事前確認 +git log --oneline --left-right main...feature/new-feature +``` + +#### 2. ブランチのクリーンアップ +```bash +# マージ済みブランチ一覧 +git branch --merged main + +# リモートの削除済みブランチを反映 +git remote prune origin + +# 一括削除スクリプト +git branch --merged main | grep -v "main\|develop" | xargs -n 1 git branch -d +``` + +#### 3. ブランチ復元 +```bash +# 削除したブランチを復元 +git reflog +git checkout -b recovered-branch HEAD@{2} +``` + +### ワークフロー例 + +#### フィーチャーブランチワークフロー +```bash +# 1. 最新のmainから分岐 +git checkout main +git pull origin main +git checkout -b feature/awesome-feature + +# 2. 開発作業 +# ... コード変更 ... +git add . +git commit -m "feat: add awesome feature" + +# 3. 定期的にmainの変更を取り込む +git checkout main +git pull origin main +git checkout feature/awesome-feature +git rebase main + +# 4. プッシュしてPR作成 +git push origin feature/awesome-feature +gh pr create --fill +``` + +--- + +## 3. 💾 コミット(Commit) + +### 概要 +コミットは、ファイルの変更を履歴として記録する操作です。各コミットは一意のIDを持ち、いつでも過去の状態に戻すことができます。 + +### コミットメッセージの規約 + +#### Conventional Commits +``` +(): + + + +