---
id: gh-pulling-updates-from-skills-repository
name: "Pulling Updates from Skills Repository"
url: https://skills.yangsir.net/skill/gh-pulling-updates-from-skills-repository
author: obra
domain: ai-skill-platform-ecosystem
tags: ["git", "repository-management", "version-control", "automation", "skill-management"]
install_count: 520
rating: 4.20 (120 reviews)
github: https://github.com/obra/superpowers-skills/tree/main/skills/meta/pulling-updates-from-skills-repository
---

# Pulling Updates from Skills Repository

> 此技能旨在帮助用户将其本地技能仓库与上游更新同步，同时保留个人修改。它自动化了 Git 拉取、合并和冲突解决流程，确保技能库始终保持最新，并有效管理自定义内容，提升技能库的维护效率和稳定性。

**Stats**: 520 installs · 4.2/5 (120 reviews)

## Before / After 对比

### 技能库同步效率

**Before**:

用户需要手动执行一系列复杂的 Git 命令来同步技能仓库，包括检查状态、暂存修改、拉取上游更新、合并分支，并手动解决可能出现的代码冲突。这不仅耗时，而且容易因操作失误导致数据丢失或仓库损坏，尤其对于不熟悉 Git 的用户来说，维护技能库的最新状态是一个巨大的挑战。

**After**:

此技能自动化了整个同步流程，从检查仓库状态到拉取、合并更新，甚至辅助解决冲突。用户只需简单操作即可确保技能库与上游保持同步，同时个人修改得到妥善保留。这显著减少了手动操作的复杂性和出错率，大幅提升了技能库的维护效率和稳定性，让用户能更专注于技能的使用而非管理。

| Metric | Before | After | Change |
|---|---|---|---|
| 手动操作时间 | 30分钟 | 5分钟 | -83% |

## Readme

# Updating Skills from Upstream

## Overview

Pull and merge upstream changes from obra/superpowers-skills into your local skills repository while preserving your personal modifications.

**Announce at start:** "I'm using the Updating Skills skill to sync with upstream."

## Prerequisites

Your skills repo must have a tracking branch configured. The plugin sets this up automatically (either as a fork with `origin` remote, or with an `upstream` remote).

## The Process

### Step 1: Check Current Status

Run:
```bash
cd ~/.config/superpowers/skills
git status
```

**If working directory is dirty:** Proceed to Step 2 (stash changes)
**If clean:** Skip to Step 3

### Step 2: Stash Uncommitted Changes (if needed)

Run:
```bash
git stash push -m "Temporary stash before upstream update"
```

Record: Whether changes were stashed (you'll need to unstash later)

### Step 3: Determine Tracking Remote and Fetch

First, detect which remote to use:
```bash
TRACKING_REMOTE=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null | cut -d'/' -f1 || echo "")
```

Then fetch from the appropriate remote:
```bash
if [ -n "$TRACKING_REMOTE" ]; then
    git fetch "$TRACKING_REMOTE" 2>/dev/null || true
else
    git fetch upstream 2>/dev/null || git fetch origin 2>/dev/null || true
fi
```

Expected: Fetches latest commits from the tracking remote (or falls back to upstream/origin)

### Step 4: Check What's New

Run:
```bash
git log HEAD..@{u} --oneline
```

Show user: List of new commits being pulled

Note: `@{u}` refers to the upstream tracking branch for your current branch

### Step 5: Merge Changes

First, try a fast-forward merge (cleanest option):
```bash
git merge --ff-only @{u}
```

**If fast-forward succeeds:** Skip to Step 7 (no conflicts possible with fast-forward)
**If fast-forward fails:** Your branch has diverged. Try regular merge:
```bash
git merge @{u}
```

**If merge succeeds cleanly:** Proceed to Step 7
**If conflicts occur:** Proceed to conflict resolution

### Step 6: Handle Merge Conflicts (if any)

If conflicts:
1. Run `git status` to see conflicted files
2. For each conflict, explain to user what changed in both versions
3. Ask user which version to keep or how to merge
4. Edit files to resolve
5. Run `git add <resolved-file>` for each
6. Run `git commit` to complete merge

### Step 7: Unstash Changes (if stashed in Step 2)

If you stashed changes:
```bash
git stash pop
```

**If conflicts with unstashed changes:** Help user resolve them

### Step 8: Verify Everything Works

Run:
```bash
${SUPERPOWERS_SKILLS_ROOT}/skills/using-skills/find-skills
```

Expected: Skills list displays correctly

### Step 9: Announce Completion

Tell user:
- How many new commits were merged
- Whether any conflicts were resolved
- Whether their stashed changes were restored
- That skills are now up to date

## Common Issues

**"Already up to date"**: Your local repo is current, no action needed

**"fatal: no upstream configured"**: Your branch isn't tracking a remote branch. Check `git remote -v` to see available remotes, then set tracking with `git branch --set-upstream-to=<remote>/<branch>`

**Detached HEAD**: You're not on a branch. Ask user if they want to create a branch or check out main.

**Fast-forward fails, diverged branches**: Your local branch has commits that aren't in the remote. Regular merge will be needed, which may cause conflicts.

## Remember

- Always stash uncommitted work before merging
- Explain conflicts clearly to user
- Test that skills work after update
- User's local commits/branches are preserved


---
*Source: https://skills.yangsir.net/skill/gh-pulling-updates-from-skills-repository*
*Markdown mirror: https://skills.yangsir.net/api/skill/gh-pulling-updates-from-skills-repository/markdown*