zc277584121/mygitplugin

git-sync-main

Sync local main branch with the latest code from official upstream or origin remote

All-time #4443 Trending #3885 Hot #5323 First seen Apr 27, 2026
8-week activity · all time api

Installation

$ npx skills add zc277584121/mygitplugin --skill git-sync-main

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from zc277584121/mygitplugin.

npx skills add zc277584121/mygitplugin

Browse all from zc277584121/mygitplugin

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

License MIT
Default branch master
Open issues 0
Status Active

Skill metadata

Parsed from SKILL.md frontmatter.

Allowed toolsBash

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 2,061 B
  • docs SUMMARY.md 104 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 2,925 installs

SKILL.md

Git Sync Main

同步最新主分支代码到本地并切换到主分支。支持两种场景:fork 的项目从 official remote 同步,自己的项目从 origin 同步。

触发条件

当用户要求同步上游代码、更新主分支、或拉取最新主分支代码时使用此 skill。

执行步骤

  1. 检查 remote 配置git remote -v,确认是否存在 official remote。
  1. 根据是否存在 official remote 分两种情况执行

情况一:存在 official remote(fork 的项目)

  1. 检测主分支名称:通过 git remote show official 或查看本地分支,确定主分支名称(mainmaster)。
  1. 拉取 official 最新代码git fetch official
  1. 切换到本地主分支git checkout <main-branch>
  1. 同步代码git reset --hard official/<main-branch>,将本地主分支重置到 official 最新状态。
  1. 推送到 origingit push origin <main-branch> --force-with-lease,同步自己 fork 的远端主分支。

情况二:不存在 official remote(自己的项目)

  1. 检测主分支名称:通过查看本地分支,确定主分支名称(mainmaster)。
  1. 拉取 origin 最新代码git fetch origin
  1. 切换到本地主分支git checkout <main-branch>
  1. 同步代码git pull origin <main-branch>,将本地主分支同步到 origin 最新状态。

共同步骤

  1. 验证结果git log --oneline -5,展示最新的几条 commit 确认同步成功。

注意事项

  • 始终使用 official 作为上游 remote 名称(而非 upstream),以保持一致性。
  • 对于 fork 项目,推送到 origin 时使用 --force-with-lease 而非 --force,更安全地强制推送。
  • 如果当前有未提交的改动,先提示用户处理(stash 或 commit),避免丢失工作。