Agent SkillsAgentsMesh/AgentsMesh › github-gitlab-mirror

github-gitlab-mirror

GitHub

审计或同步 GitHub 主分支到内部 GitLab 镜像,确保两者一致。支持快速转发更新及分歧处理,通过 SHA 比对验证状态,防止错误推送,保障代码仓库一致性。

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

触发场景

检查 GitHub 与 GitLab 一致性 更新内部 GitLab 镜像 解决双远程仓库分歧

安装

npx skills add AgentsMesh/AgentsMesh --skill github-gitlab-mirror -g -y
更多选项

非标准路径

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

不安装直接使用

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.

版本历史

  • 9fc2f49 当前 2026-07-24 21:57

同 Skill 集合

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

元信息

文件数
0
版本
1f90b14
Hash
0c304472
收录时间
2026-07-24 21:57

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-17 20:13
浙ICP备14020137号-1