Agent SkillsAgentsMesh/AgentsMesh › github-gitlab-mirror

github-gitlab-mirror

GitHub

审计并同步 GitHub 主分支至内部 GitLab 镜像,确保两者一致性。支持快速转发更新及分叉修复,严格禁止将 GitLab 独有提交推回 GitHub,保障代码源单一性。

agents/skills/github-gitlab-mirror/SKILL.md AgentsMesh/AgentsMesh

Trigger Scenarios

检查 GitHub 与 GitLab 仓库一致性 更新内部 GitLab 镜像 解决两个远程仓库之间的分叉

Install

npx skills add AgentsMesh/AgentsMesh --skill github-gitlab-mirror -g -y
More Options

Non-standard path

npx skills add https://github.com/AgentsMesh/AgentsMesh/tree/main/agents/skills/github-gitlab-mirror -g -y

Use without installing

npx skills use AgentsMesh/AgentsMesh@github-gitlab-mirror

指定 Agent (Claude Code)

npx skills add AgentsMesh/AgentsMesh --skill github-gitlab-mirror -a claude-code -g -y

安装 repo 全部 skill

npx skills add AgentsMesh/AgentsMesh --all -g -y

预览 repo 内 skill

npx skills add AgentsMesh/AgentsMesh --list

SKILL.md

Frontmatter
{
    "name": "github-gitlab-mirror",
    "description": "Audits or synchronizes the authoritative GitHub main branch to the internal GitLab mirror without importing GitLab-only history back into GitHub. Use when checking GitHub\/GitLab consistency, updating the internal mirror, or resolving a divergence between the two remotes."
}

GitHub to GitLab Mirror

GitHub main is the single source of truth. GitLab exists to build and deploy the same commit internally.

Safety Rules

  • Discover both remotes from their URLs; do not assume they are named origin and gitlab.
  • Never merge, cherry-pick, or push GitLab-only commits into GitHub.
  • A fast-forward update to GitLab may proceed after verification.
  • Rewriting a divergent GitLab branch requires explicit user authorization and an exact --force-with-lease expectation.
  • Do not change the local branch or working tree to mirror remote refs.

Status

  1. Fetch both authoritative refs:

    git remote -v
    git fetch <github-remote> main
    git fetch <gitlab-remote> main
    
  2. Record both SHAs and show commits unique to either side:

    git rev-parse <github-remote>/main
    git rev-parse <gitlab-remote>/main
    git log --oneline <gitlab-remote>/main..<github-remote>/main
    git log --oneline <github-remote>/main..<gitlab-remote>/main
    
  3. Classify the relationship:

    • Equal: already mirrored.
    • GitLab is an ancestor of GitHub: safe fast-forward.
    • GitHub is an ancestor of GitLab: GitLab contains mirror-only commits.
    • Neither is an ancestor: the remotes diverged.

Synchronize

For a verified fast-forward:

git push <gitlab-remote> <github-remote>/main:refs/heads/main

For a GitLab-ahead or divergent branch, stop and display the GitLab-only commits. An explicit request to restore GitLab as the GitHub mirror authorizes discarding those mirror-only commits. Use the previously fetched GitLab SHA as the lease:

git push \
  --force-with-lease=refs/heads/main:<expected-gitlab-sha> \
  <gitlab-remote> \
  <github-remote>/main:refs/heads/main

If the lease fails, fetch and reassess instead of weakening the protection.

Verify

Fetch both remotes again and require exact SHA equality from fresh refs:

git fetch <github-remote> main
git fetch <gitlab-remote> main
test "$(git rev-parse <github-remote>/main)" = \
  "$(git rev-parse <gitlab-remote>/main)"

If GitHub advanced during the synchronization, return to the Status phase and mirror the new SHA. Do not claim success until one fresh fetch of both remotes observes equality.

Report both final SHAs and whether the GitLab build/deploy pipeline was triggered. Do not describe the mirror as synchronized until the SHAs match. The scheduled mirror job in .gitlab-ci.yml is the automation reference.

Version History

  • 9fc2f49 Current 2026-07-24 21:57

Same Skill Collection

agents/skills/arch-check/SKILL.md
agents/skills/e2e/SKILL.md
agents/skills/gh-merge/SKILL.md
agents/skills/worktree/SKILL.md

Metadata

Files
0
Version
1f90b14
Hash
0c304472
Indexed
2026-07-24 21:57

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-21 14:10
浙ICP备14020137号-1 $Гость$