基于 SOC 职业分类
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/vamseeachanta/workspace-hub --skill git-sync-manager命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
Write outbound email and external messages in Vamsee Achanta's voice — a subtle offer to help, never bold or rash claims. Load before drafting ANY email, LinkedIn/Collide reply, proposal note, or outreach sent under his name.
Save/publish analysis or computation results from ANY ecosystem repo to Hugging Face as a queryable, viewer-renderable dataset. Use when the user wants to "save results to hugging face", "publish dataset to HF", "hugging face data saving", "save analysis results", "hf dataset", "make results queryable", or "render via datasets-server API". Reshapes nested results into flat parquet tables, writes a dataset card with a viewer `configs:` block and provenance, applies license/public-vs-private routing, enforces a domain data-quality gate (faithful-to-source != correct), publishes to `aceengineer/<repo>-<projection>`, and verifies via the datasets-server API.
Clone, create, fork, configure, and manage GitHub repositories. Manage remotes, secrets, releases, and workflows. Works with gh CLI or falls back to git + GitHub REST API via curl.
| name | git-sync-manager |
| version | 1.0.0 |
| description | Multi-repository git synchronization patterns for batch operations |
| author | workspace-hub |
| category | bash |
| tags | ["bash","git","sync","multi-repo","batch","automation"] |
| platforms | ["linux","macos"] |
Patterns for synchronizing multiple Git repositories with phased operations, status tracking, and error handling. Extracted from workspace-hub's repository sync scripts.
✅ Use when:
❌ Avoid when:
Automatically discover repositories listed in .gitignore:
#!/bin/bash
# ABOUTME: Discover repositories from .gitignore patterns
# ABOUTME: Parses directory entries and validates git repos
WORKSPACE_ROOT="${1:-.}"
# Discover repositories from .gitignore
discover_repos() {
local repos=()
while IFS= read -r line; do
# Skip comments and empty lines
[[ "$line" =~ ^[[:space:]]*# ]] && continue
[[ -z "$line" ]] && continue
# Extract repo name (before the /)
local repo_name="${line%%/*}"
[[ -z "$repo_name" ]] && continue
# Check if directory exists and is a git repo
if [[ -d "$WORKSPACE_ROOT/$repo_name/.git" ]]; then
repos+=("$repo_name")
fi
done < <(grep -v "^[[:space:]]*#" "$WORKSPACE_ROOT/.gitignore" | grep "/" | head -100)
printf '%s\n' "${repos[@]}"
}
# Usage
REPOS=($(discover_repos))
echo "Found ${#REPOS[@]} repositories"
Execute git operations in ordered phases:
#!/bin/bash
# ABOUTME: Multi-phase git synchronization
# ABOUTME: Executes pull → commit → push in controlled phases
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m'
# Counters
SUCCESS=0
FAILED=0
SKIPPED=0
# ─────────────────────────────────────────────────────────────────
# Phase 1: Pull
# ─────────────────────────────────────────────────────────────────
phase_pull() {
local repos=("$@")
echo -e "${CYAN}PHASE 1: Pulling latest changes${NC}"
echo -e "${CYAN}─────────────────────────────────${NC}"
for repo in "${repos[@]}"; do
if [[ -d "$repo/.git" ]]; then
echo -n "→ Pulling $repo... "
local branch
branch=$(cd "$repo" && git rev-parse --abbrev-ref HEAD 2>/dev/null)
if (cd "$repo" && git pull origin "$branch" 2>&1 | grep -qE );
-e
((SUCCESS++))
( && git pull origin &>/dev/null);
-e
((SUCCESS++))
-e
((SKIPPED++))
}
() {
repos=()
message=
-e
-e
repo ;
[[ -d ]];
has_changes=
! ( && git diff --quiet 2>/dev/null);
has_changes=
! ( && git diff --cached --quiet 2>/dev/null);
has_changes=
[[ == ]];
-n
( && git add -A && git commit -m --no-verify 2>/dev/null);
-e
((SUCCESS++))
-e
((SKIPPED++))
-e
((SKIPPED++))
}
() {
repos=()
-e
-e
repo ;
[[ -d ]];
branch
branch=$( && git rev-parse --abbrev-ref HEAD 2>/dev/null)
-n
( && git push origin 2>&1 | grep -qE );
-e
((SUCCESS++))
( && git push origin &>/dev/null);
-e
((SUCCESS++))
-e
((FAILED++))
}
() {
repos=()
phase_pull
phase_commit
phase_push
-e
-e
-e
-e
-e
-e
-e
}
Get detailed status for multiple repositories:
#!/bin/bash
# ABOUTME: Check git status across multiple repositories
# ABOUTME: Reports uncommitted, unpushed, and behind-remote states
check_repo_status() {
local repo="$1"
if [[ ! -d "$repo/.git" ]]; then
echo "not_git"
return
fi
cd "$repo" || return
# Check for uncommitted changes
if ! git diff --quiet 2>/dev/null || ! git diff --cached --quiet 2>/dev/null; then
echo "uncommitted"
return
fi
# Check for unpushed commits
local branch
branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
local ahead
ahead=$(git rev-list --count "origin/$branch..HEAD" 2>/dev/null || echo "0")
if [[ "$ahead" -gt 0 ]]; then
echo "unpushed"
return
fi
# Check if behind remote
git fetch origin "$branch" --quiet 2>/dev/null
local behind
behind=$(git rev-list --count "HEAD..origin/$branch" 2>/dev/null || )
[[ -gt 0 ]];
}
() {
repos=()
repo ;
status
status=$(check_repo_status )
branch=
[[ -d ]];
branch=$( && git rev-parse --abbrev-ref HEAD 2>/dev/null)
color=
clean) color= ;;
uncommitted) color= ;;
unpushed) color= ;;
behind) color= ;;
*) color= ;;
}
Filter repositories by category (Work/Personal):
#!/bin/bash
# ABOUTME: Category-based repository filtering
# ABOUTME: Parse categories from .gitignore comments
declare -A REPO_CATEGORIES
# Parse categories from .gitignore comments
# Format: repo_name/ # Category
parse_categories() {
local gitignore="$1"
while IFS= read -r line; do
if [[ "$line" =~ ^([a-zA-Z0-9_-]+)/[[:space:]]*#[[:space:]]*(Personal|Work|Both)$ ]]; then
local name="${BASH_REMATCH[1]}"
local category="${BASH_REMATCH[2]}"
REPO_CATEGORIES["$name"]="$category"
fi
done < "$gitignore"
}
# Get repos by category
get_repos_by_category() {
local target_category="$1"
local repos=()
for repo in "${!REPO_CATEGORIES[@]}"; do
local category="${REPO_CATEGORIES[$repo]}"
if [[ "$category" == ]] || \
[[ == ]] || \
[[ =~ ]];
repos+=()
|
}
parse_categories
get_repos_by_category
get_repos_by_category
Switch branches safely across repositories:
#!/bin/bash
# ABOUTME: Safe branch switching across repositories
# ABOUTME: Validates branch existence and checks for uncommitted changes
switch_branch() {
local repo="$1"
local target_branch="$2"
if [[ ! -d "$repo/.git" ]]; then
echo "skip: not a git repo"
return 1
fi
cd "$repo" || return 1
# Check for uncommitted changes
if ! git diff --quiet 2>/dev/null || ! git diff --cached --quiet 2>/dev/null; then
echo "blocked: uncommitted changes"
return 1
fi
# Check if branch exists locally
if git show-ref --verify --quiet "refs/heads/$target_branch" 2>/dev/null; then
git checkout "$target_branch" 2>/dev/null
echo "switched: local branch"
return 0
fi
# Check if branch exists remotely
if git show-ref --verify --quiet "refs/remotes/origin/$target_branch" 2>/dev/null; then
git checkout -b "" 2>/dev/null
0
1
}
() {
target_branch=
repos=()
repo ;
-n
switch_branch
}
Full implementation combining all patterns:
#!/bin/bash
# ABOUTME: Complete multi-repository sync manager
# ABOUTME: Provides pull, commit, push, sync, and status operations
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WORKSPACE_ROOT="${WORKSPACE_ROOT:-$(dirname "$SCRIPT_DIR")}"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m'
# ─────────────────────────────────────────────────────────────────
# Repository Discovery
# ─────────────────────────────────────────────────────────────────
declare -a REPOS=()
declare -A CATEGORIES=()
discover_repos() {
REPOS=()
while IFS= read -r line; do
[[ "$line" =~ ^[[:space:]]*# ]] && continue
[[ -z "$line" ]] && continue
local repo_name="${line%%/*}"
[[ -z "$repo_name" ]] && continue
if [[ -d "$WORKSPACE_ROOT/$repo_name/.git" ]]; then
REPOS+=("$repo_name")
# Extract category from comment
[[ =~
CATEGORIES[]=
< <(grep 2>/dev/null | -100)
}
() {
repos=()
success=0 failed=0
repo ;
-n
( && git pull --quiet 2>/dev/null);
-e
((success++))
-e
((failed++))
}
() {
message=
repos=()
committed=0 skipped=0
repo ;
( && ! git diff --quiet) || \
( && ! git diff --cached --quiet);
-n
( && git add -A && git commit -m --no-verify &>/dev/null);
-e
((committed++))
-e
((skipped++))
}
() {
repos=()
success=0 failed=0
repo ;
-n
branch
branch=$( && git rev-parse --abbrev-ref HEAD)
( && git push origin --quiet 2>/dev/null);
-e
((success++))
-e
((failed++))
}
() {
message=
repos=()
-e
do_pull
do_commit
do_push
}
() {
repos=()
repo ;
category=
branch status
branch=$( && git rev-parse --abbrev-ref HEAD 2>/dev/null || )
! ( && git diff --quiet 2>/dev/null);
status=
[[ $( && git rev-list --count 2>/dev/null || 0) -gt 0 ]];
status=
status=
}
() {
<<
}
() {
=
scope=
message=
2 2>/dev/null ||
[[ -gt 0 ]];
-m|--message) message=; 2 ;;
*) ;;
discover_repos
filtered_repos=()
repo ;
=
all) filtered_repos+=() ;;
work) [[ == || == ]] && filtered_repos+=() ;;
personal) [[ == || == ]] && filtered_repos+=() ;;
list) ;;
pull) do_pull ;;
commit) do_commit ;;
push) do_push ;;
) do_sync ;;
status) do_status ;;
|*) show_usage ;;
}
main
# Check for uncommitted changes before destructive operations
if ! git diff --quiet; then
echo "Error: uncommitted changes"
exit 1
fi
# Skip hooks in batch operations for speed
git commit -m "message" --no-verify
# Suppress errors and provide fallback
if ! git pull --quiet 2>/dev/null; then
echo "Warning: could not pull (offline?)"
fi
# Always maintain counters for summary
SUCCESS=0; FAILED=0; SKIPPED=0
# Update appropriately in each operation
# Always check .git directory exists
[[ -d "$repo/.git" ]] || continue