Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
zc277584121 avatar

Git Sync Main

  • 2.3k installs
  • Updated April 27, 2026
  • zc277584121/mygitplugin

Automated bash workflow that fetches and resets local main branch to match official (forked projects) or origin (personal projects) remote state.

About

git-sync-main automates synchronization of the local main branch with remote sources via Bash commands. For forked projects, it fetches from an 'official' remote, resets the local main branch, and force-pushes to origin; for personal projects, it fetches and pulls from origin directly. The skill detects the main branch name (main or master), verifies remote configuration, and validates success by displaying recent commits. Developers use this to keep their local main branch up-to-date with upstream changes or their own remote repositories without manual multi-step workflows.

  • Detects main branch name (main or master) automatically
  • Handles forked projects via official remote with safe --force-with-lease push
  • Handles personal projects via origin remote with standard pull
  • Verifies sync success by displaying latest 5 commits
  • Prompts user to stash or commit unsaved changes before proceeding

Git Sync Main by the numbers

  • 2,331 all-time installs (skills.sh)
  • +188 installs in the week ending Aug 5, 2026 (Skillselion tracking)
  • Ranked #38 of 733 Git & Pull Requests skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
At a glance

git-sync-main capabilities & compatibility

Capabilities
detect main branch name dynamically · check remote configuration · fetch from official or origin · reset or pull local branch · force push with safeguards · validate sync success
Works with
github · gitlab · bitbucket
Use cases
code review
Platforms
macOS · Linux · WSL · Windows
Runs
Runs locally
From the docs

What git-sync-main says it does

同步最新主分支代码到本地并切换到主分支。支持两种场景:fork 的项目从 official remote 同步,自己的项目从 origin 同步。
skill:zc277584121/mygitplugin#git-sync-main description
对于 fork 项目,推送到 origin 时使用 `--force-with-lease` 而非 `--force`,更安全地强制推送。
skill:zc277584121/mygitplugin#git-sync-main 注意事项
如果当前有未提交的改动,先提示用户处理(stash 或 commit),避免丢失工作。
skill:zc277584121/mygitplugin#git-sync-main 注意事项
npx skills add https://github.com/zc277584121/mygitplugin --skill git-sync-main

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs2.3k
Security audit3 / 3 scanners passed
Last updatedApril 27, 2026
Repositoryzc277584121/mygitplugin

What it does

Synchronize a local main branch with upstream or origin remote, handling both forked and personal projects.

Who is it for?

Developers maintaining forked repositories or personal projects who need frequent local-remote synchronization.

Skip if: Projects using non-standard branch naming or custom remote naming schemes; situations requiring selective cherry-picking or merge strategies.

When should I use this skill?

User requests upstream sync, main branch update, or latest code pull; before starting new feature branches on main.

What you get

Local main branch synchronized to latest remote state in single invocation, with verification output confirming success.

  • Local main branch synchronized to remote state
  • Console output showing latest 5 commits as confirmation

By the numbers

  • Handles 2 distinct remote configurations: official (fork) and origin (personal)
  • Detects 2 main branch variants: main or master
  • Displays latest 5 commits for verification

Files

SKILL.mdMarkdownGitHub ↗

Git Sync Main

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

触发条件

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

执行步骤

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

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

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

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

4. 拉取 official 最新代码git fetch official

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

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

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

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

3. 检测主分支名称:通过查看本地分支,确定主分支名称(mainmaster)。

4. 拉取 origin 最新代码git fetch origin

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

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

共同步骤

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

注意事项

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

Related skills

FAQ

What is the difference between the two execution paths?

Forked projects use 'official' remote with git reset --hard and --force-with-lease push; personal projects use 'origin' with git pull. The skill auto-detects which scenario applies.

Why --force-with-lease instead of --force?

Safe-guards against overwriting concurrent changes on origin by aborting if remote has been updated since last fetch.

What happens if I have uncommitted changes?

Skill prompts user to stash or commit changes before proceeding to avoid losing work.

Is Git Sync Main safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.