brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
configure-git-repositoryGitリポジトリを適切な.gitignore、ブランチ戦略、コミット規約、 フック、リモート設定で構成します。新規プロジェクトの初期設定、 特定言語・フレームワーク向けの.gitignore追加、ブランチ保護と 規約の設定、コミットフックの構成に対応。R、Node.js、Pythonプロジェクトの 一般的なパターンも網羅。
Independent GitHub snapshot · Automated classification · Original documentation governs
プロジェクトの種類に応じた適切な設定でGitリポジトリをセットアップする。
.gitignoreを追加するときcd /path/to/project
git init
git branch -M main
期待結果: .git/ ディレクトリが作成される。デフォルトブランチが main という名前になる。
失敗時: git init が失敗する場合、Gitがインストールされているか確認する(git --version)。すでに .git/ が存在する場合、リポジトリはすでに初期化済みのため、このステップをスキップする。
Rパッケージ:
# R artifacts
.Rhistory
.RData
.Rproj.user/
*.Rproj
# Environment (sensitive)
.Renviron
# renv library (machine-specific)
renv/library/
renv/staging/
renv/cache/
# Build artifacts
*.tar.gz
src/*.o
src/*.so
src/*.dll
# Documentation build
docs/
inst/doc/
# IDE
.vscode/
.idea/
# OS
.DS_Store
Thumbs.db
Node.js/TypeScript:
node_modules/
dist/
build/
.next/
.env
.env.local
.env.*.local
*.log
npm-debug.log*
.DS_Store
Thumbs.db
.vscode/
.idea/
coverage/
Python:
__pycache__/
*.py[cod]
*.egg-info/
dist/
build/
.eggs/
.venv/
venv/
.env
*.log
.mypy_cache/
.pytest_cache/
htmlcov/
.coverage
.DS_Store
.idea/
.vscode/
期待結果: プロジェクトの種類に適したエントリを含む .gitignore ファイルが作成される。機密ファイル(.Renviron、.env)と生成物が除外されている。
失敗時: どのエントリを含めるか不明な場合、gitignore.io またはGitHubの .gitignore テンプレートを出発点として利用し、プロジェクトに合わせてカスタマイズする。
git add .gitignore
git add . # Review what's being added first with git status
git commit -m "Initial project setup"
期待結果: .gitignore と初期プロジェクトファイルを含む最初のコミットが作成される。git log に1件のコミットが表示される。
失敗時: git commit が「nothing to commit」で失敗する場合、git add でファイルがステージングされているか確認する。作成者情報エラーで失敗する場合、git config user.name と git config user.email を設定する。
# Add remote
git remote add origin git@github.com:username/repo.git
# Push
git push -u origin main
期待結果: リモート origin が設定される。git remote -v にフェッチとプッシュのURLが表示される。初期コミットがリモートにプッシュされる。
失敗時: 「Permission denied (publickey)」でプッシュが失敗する場合、SSHキーを設定する(setup-wsl-dev-environment を参照)。リモートがすでに存在する場合、git remote set-url origin <url> で更新する。
トランクベース(小規模チームに推奨):
main: 本番環境対応コードfeature/descriptionfix/description# Create feature branch
git checkout -b feature/add-authentication
# After work is done, merge or create PR
git checkout main
git merge feature/add-authentication
期待結果: ブランチ命名規約が確立され、文書化される。チームメンバーが各作業種別に使うプレフィックスを把握している。
失敗時: ブランチがすでに一貫性なく命名されている場合、git branch -m old-name new-name でリネームし、オープン中のPRも更新する。
Conventional Commits形式:
type(scope): description
feat: add user authentication
fix: correct calculation in weighted_mean
docs: update README installation section
test: add edge case tests for parser
refactor: extract helper function
chore: update dependencies
期待結果: コミットメッセージ規約がチームで合意・文書化される。今後のコミットが type: description 形式に従う。
失敗時: チームメンバーが規約に従っていない場合、フォーマットを検証するcommit-msgフックで強制する(ステップ7を参照)。
.githooks/pre-commit を作成:
#!/bin/bash
# Run linter before commit
# For R packages
if [ -f "DESCRIPTION" ]; then
Rscript -e "lintr::lint_package()" || exit 1
fi
# For Node.js
if [ -f "package.json" ]; then
npm run lint || exit 1
fi
chmod +x .githooks/pre-commit
git config core.hooksPath .githooks
期待結果: プリコミットフックが git commit のたびに自動で実行される。リントエラーがあるとコミットがブロックされ、修正が必要になる。
失敗時: フックが実行されない場合、core.hooksPath が設定されているか(git config core.hooksPath)およびフックファイルが実行可能か(chmod +x)を確認する。
# Minimal README
echo "# Project Name" > README.md
echo "" >> README.md
echo "Brief description of the project." >> README.md
git add README.md
git commit -m "Add README"
期待結果: README.md がリポジトリにコミットされる。GitHubに最小限の情報を持つランディングページが作成される。
失敗時: README.md がすでに存在する場合、上書きせず更新する。Rプロジェクトではバッジつきのテンプレートとして usethis::use_readme_md() を使用する。
.gitignore が機密ファイルと生成物を除外している.gitignore を追加すること。すでに追跡されているファイルは後から .gitignore に追加しても影響を受けない。git filter-repo またはBFGを使用する。core.autocrlf=input を設定してCRLF/LFの問題を防ぐ。commit-changes - ステージングとコミットのワークフローmanage-git-branches - ブランチの作成と規約create-r-package - Rパッケージ作成の一環としてのGitセットアップsetup-wsl-dev-environment - GitのインストールとSSHキーcreate-github-release - リポジトリからのリリース作成security-audit-codebase - コミットされたシークレットのチェック