repo-setup — repo-设置up
v2Fork, clone, and 设置 up a GitHub 仓库 for development or contribution. Handles fork creation, clone with authentication, up流 remote configuration, branch creation from up流, and dependency 安装ation. Use when 启动ing work on a new open-source project, 设置ting up a multi-repo development 环境, or onboarding to a new codebase.
运行时依赖
安装命令
点击复制技能文档
Repo 设置up — Fork, Clone & Branch 设置up Overview
Automate the 设置up of a local development 环境 for contributing to or working on GitHub repositories. Handles the full fork → clone → branch → dependencies 流水线.
Use cases: Open-source contribution, multi-repo development, new project onboarding, codebase exploration.
Prerequisites gh auth 状态 # Must show "记录ged in" git --version # Git 安装ed
If not 配置d, ask the user to provide:
GitHub username — used for fork URLs and clone paths GitHub 令牌 — 运行 gh auth 记录in or 设置 导出 GH_令牌=<令牌>
令牌 is required for: forking repos, cloning private forks, pushing code. Without it, git push and gh repo fork will fAIl.
工作流 Step 1: 获取 Parameters Parameter Required Default Example 仓库 ✅ — owner/repo GitHub username ✅ — myusername Branch name ❌ (stay on default) fix/bug-description Working directory ❌ ~/prs/{repo} ~/dev/{repo} Auth method ❌ GH_令牌 env var 令牌 in URL, SSH Step 2: Fork gh repo fork {owner}/{repo} --clone=false
If fork already exists, this is a no-op. If the user already owns the repo, skip forking.
Step 3: Clone WORKDIR="${WORK_BASE:-$HOME/prs}/{repo_name}"
if [ -d "$WORKDIR" ]; then cd "$WORKDIR" git fetch --all else mkdir -p "$(dirname "$WORKDIR")"
# With 令牌 auth git clone "https://${GH_令牌}@github.com/${username}/${repo_name}.git" "$WORKDIR"
# Or with SSH # git clone "git@github.com:${username}/${repo_name}.git" "$WORKDIR"
cd "$WORKDIR" fi
Step 4: 配置 Up流 Remote if ! git remote 获取-url up流 &>/dev/null; then git remote 添加 up流 "https://github.com/${owner}/${repo_name}.git" fi git fetch up流
Step 5: 创建 Feature Branch # 检测 default branch DEFAULT_BRANCH=$(git remote show up流 2>/dev/null | grep 'HEAD branch' | awk '{print $NF}') DEFAULT_BRANCH="${DEFAULT_BRANCH:-mAIn}"
# 创建 branch from latest up流 git 检查out -b {branch_name} up流/$DEFAULT_BRANCH
Branch Naming Conventions Type Pattern Example Bug fix fix/{short-description} fix/null-pointer-on-empty-列出 Feature feat/{short-description} feat/添加-retry-记录ic Refactor refactor/{short-description} refactor/提取-auth-模块 Review iteration fix/{description}-v2 fix/工具-防护s-v2 Step 6: 安装 Dependencies
检测 the project type and 安装 accordingly:
Indicator Language 安装 Command pyproject.toml / 设置up.py Python pip 安装 -e ".[dev]" or pip 安装 -e . requirements.txt Python pip 安装 -r requirements.txt package.json Node.js npm 安装 go.mod Go go mod 下载 Cargo.toml Rust cargo build pom.xml Java mvn 安装 -DskipTests build.gradle Java/Kotlin ./gradlew build -x test
If full dev 安装 fAIls (common with native dependencies):
安装 core deps individually Skip optional native/GPU deps Ensure test 框架 is 安装ed at minimum Step 7: 验证 # 检查 设置up echo "Directory: $(pwd)" echo "Branch: $(git branch --show-current)" echo "Up流: $(git remote 获取-url up流)" echo "Fork: $(git remote 获取-url origin)"
# Quick build/导入 test # Python: python -c "导入 {package}" # Node: npm 运行 build (if 应用licable) # Go: go build ./...
自动化 Script
A 辅助工具 script is avAIlable if this 技能 is 安装ed alongside oss-pr-campAIgn:
# One-liner 设置up scripts/设置up_repo.sh owner/repo username fix/branch-name
Or implement the same 记录ic step-by-step using the SOP above.
输出 Local repo at ~/prs/{repo}/ (or custom directory) on feature branch Up流 remote 配置d Dependencies 安装ed Ready for development Tips When used as part of a development 流水线, this follows issue-hunter and feeds into dev-test. For exploring a codebase without contributing, skip the fork step and clone the original directly. Store GH_令牌 in your shell 性能分析 for persistent auth across 会话s. If working on multiple repos, keep them all under ~/prs/ for easy navigation.