MCPInstall

git-sync-main

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

Installs
3.4K
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/zc277584121/mygitplugin --skill git-sync-main
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads git-sync-main automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Git Sync Main

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

触发条件

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

执行步骤

  1. 检查 remote 配置:git remote -v,确认是否存在 official remote。

  2. 根据是否存在 official remote 分两种情况执行:

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

  1. 检测主分支名称:通过 git remote show official 或查看本地分支,确定主分支名称(main 或 master)。

  2. 拉取 official 最新代码:git fetch official。

  3. 切换到本地主分支:git checkout <main-branch>。

  4. 同步代码:git reset --hard official/<main-branch>,将本地主分支重置到 official 最新状态。

  5. 推送到 origin:git push origin <main-branch> --force-with-lease,同步自己 fork 的远端主分支。

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

  1. 检测主分支名称:通过查看本地分支,确定主分支名称(main 或 master)。

  2. 拉取 origin 最新代码:git fetch origin。

  3. 切换到本地主分支:git checkout <main-branch>。

  4. 同步代码:git pull origin <main-branch>,将本地主分支同步到 origin 最新状态。

共同步骤

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

注意事项

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

FAQ

What does the git-sync-main skill do?

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

How do I install git-sync-main?

Run npx skills add https://github.com/zc277584121/mygitplugin --skill git-sync-main in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/git-sync-main/ (personal) or .claude/skills/git-sync-main/ (project).

Which AI agents can use git-sync-main?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is git-sync-main safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains git-sync-main?

It is published by zc277584121 in zc277584121/mygitplugin. It has 3,354 recorded installs.

More from zc277584121/mygitplugin

View all →

git-create-repo

zc277584121/mygitplugin

Create a new GitHub repository and clone it locally

git-commit-push

zc277584121/mygitplugin

Commit changes and push to origin without creating a PR

git-commit-pr

zc277584121/mygitplugin

Commit changes and create a pull request to the official upstream repo

git-fork-clone

zc277584121/mygitplugin

Fork a GitHub repo and clone it locally with proper remote setup

git-summarize-weekly

zc277584121/mygitplugin

Summarize weekly GitHub contributions for writing weekly reports

git-get-notification

zc277584121/mygitplugin

Check GitHub notifications and recent Issues/PRs for monitored repos

Popular code quality & workflow skills

View category →

grill-me

mattpocock/skills

A relentless interview to sharpen a plan or design.

Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.

handoff

mattpocock/skills

Compact the current conversation into a handoff document for another agent to pick up.

domain-modeling

mattpocock/skills

Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.

codebase-design

mattpocock/skills

Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.

diagnosing-bugs

mattpocock/skills

Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.