<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Sync on</title><link>https://coolbeevip.github.io/tags/sync/</link><description>Recent content in Sync on</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Mon, 04 May 2026 10:00:00 +0800</lastBuildDate><atom:link href="https://coolbeevip.github.io/tags/sync/index.xml" rel="self" type="application/rss+xml"/><item><title>Git 仓库主分支镜像同步（保留 Commit 历史）</title><link>https://coolbeevip.github.io/posts/git/how-to-sync-git-repositories/</link><pubDate>Mon, 04 May 2026 10:00:00 +0800</pubDate><guid>https://coolbeevip.github.io/posts/git/how-to-sync-git-repositories/</guid><description>最近需要将一个 Git 仓库 A 的 master 分支定期同步到另一个 GitLab 仓库 B，并且要求：
保留 A 的所有 commit 历史 B 最终以 A 为准 后续支持定期同步 最终整理了一套稳定可复用的方案。
场景 源仓库 A：
ssh://git@example.com:10022/group/source-repo.git 目标仓库 B：
http://gitlab.example.com/group/target-repo.git 目标：
A/master -&amp;gt; B/master 并且：
保留所有 commit 后续支持自动同步 为什么不使用 git push &amp;ndash;mirror 一开始尝试：
git push --mirror target 会遇到：
deny updating a hidden ref 因为 GitLab 内部存在：
refs/merge-requests/* 这些隐藏 refs 不允许推送。
另外：
master -&amp;gt; master (forced update) 说明：
A/master 与 B/master 历史不一致 因此：</description></item></channel></rss>