协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
configure-git-repository【开发与工程】Configure a Git repository with proper .gitignore, branch strategy, commit conventions, hooks, and remote setup. Covers initial setup and common patterns for R, Node.js, and Python projects. Use when initializing version control for a new project, adding a .gitignore for a specific language or framework, setting up branch protection and conventions, …
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Set up Git repo with appropriate config for project type.
.gitignore for specific language/frameworkcd /path/to/project
git init
git branch -M main
Got: .git/ directory created. Default branch named main.
If fail: git init fails? Ensure Git installed (git --version). Directory already has .git/? Repo already initialized — skip.
R Package:
# 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/
Got: .gitignore created with entries appropriate for project type. Sensitive files (.Renviron, .env) and generated artifacts excluded.
If fail: Unsure which entries to include? Use gitignore.io or GitHub .gitignore templates as starting point, customize for project.
git add .gitignore
git add . # Review what's being added first with git status
git commit -m "Initial project setup"
Got: First commit created containing .gitignore and initial project files. git log shows one commit.
If fail: git commit fails with "nothing to commit"? Ensure files staged with git add. Fails with author identity error? Set git config user.name and git config user.email.
# Add remote
git remote add origin git@github.com:username/repo.git
# Push
git push -u origin main
Got: Remote origin configured. git remote -v shows fetch and push URLs. Initial commit pushed to remote.
If fail: Push fails with "Permission denied (publickey)"? Configure SSH keys (see setup-wsl-dev-environment). Remote already exists? Update with git remote set-url origin <url>.
Trunk-based (recommended for small teams):
main: production-ready codefeature/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
Got: Branch naming convention established, documented. Team members know which prefix to use for each type of work.
If fail: Branches already named inconsistently? Rename with git branch -m old-name new-name, update any open PRs.
Conventional Commits format:
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
Got: Commit message convention documented, agreed by team. Future commits follow type: description format.
If fail: Team members not following convention? Enforce with commit-msg hook that validates format (see Step 7).
Create .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
Got: Pre-commit hook runs automatically on each git commit. Linting errors block commit until fixed.
If fail: Hook does not run? Verify core.hooksPath set (git config core.hooksPath), hook file executable (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"
Got: README.md committed to repo. Project has minimal but informative landing page on GitHub.
If fail: README.md already exists? Update rather than overwrite. Use usethis::use_readme_md() in R projects for template with badges.
.gitignore excludes sensitive and generated files.gitignore first. Files already tracked aren't affected by later .gitignore entries.git filter-repo or BFG to clean.core.autocrlf=input on Windows/WSL to prevent CRLF/LF issues.commit-changes - staging and committing workflowmanage-git-branches - branch creation and conventionscreate-r-package - Git setup as part of R package creationsetup-wsl-dev-environment - Git installation and SSH keyscreate-github-release - creating releases from reposecurity-audit-codebase - check for committed secrets