如何使两个git存储库完全相同?

如何使两个git存储库完全相同?,git,Git,情景: 我有两个git存储库,分别称为,volatile和template 模板是一种只读回购协议,被视为“原始” volatile和template都存在于多个(至少两个)上游遥控器上 volatile以与模板相同的副本开始。 这是通过从模板内部用力推压volatile完成的,如下所示: cd template; git push -f remote-url1:volatile --prune git push -f remote-url2:volatile --prune 对volatil

情景:

我有两个git存储库,分别称为,
volatile
template

模板
是一种只读回购协议,被视为“原始”

volatile
template
都存在于多个(至少两个)上游遥控器上

volatile
以与
模板相同的副本开始。
这是通过从
模板内部用力推压
volatile
完成的,如下所示:

cd template;
git push -f remote-url1:volatile --prune
git push -f remote-url2:volatile --prune
对volatile执行一些操作后,volatile的状态会发生变化。 添加分支、标记和提交

如何使
volatile
模板
(在遥控器上)相同


我当前可以通过执行以下操作重置分支:

 # On my local machine
cd template;
git push -f remote-url1:volatile 'refs/remotes/origins/*:refs/heads/*' --prune
git push -f remote-url2:volatile 'refs/remotes/origins/*:refs/heads/*' --prune
我试过使用

cd template;
git push -f remote-url1:volatile --tags --prune


删除添加在遥控器上的标签,但这似乎会产生混合的结果(我有时不能删除标签,遥控器说一切都是最新的)

到目前为止,最好的选择似乎是:

cd template;
git push -f remote-url1:volatile 'refs/remotes/origin/*:refs/heads/' --prune
git push -f remote-url1:volatile '+refs/tags/*:refs/tags/*' --prune

你能简单地
git clone remote-url1:template volatile
?@JohnZwinck我在本地这样做,但我不能为远程设备这样做。你能
rsync
到远程设备吗?@JohnZwinck不幸的是,我不能。如果我可以远程访问底层存储库,这个问题将是一个没有实际意义的问题,我只需将原始的repo吹走,克隆
模板
,并正确地重命名它们。
cd template;
git push -f remote-url1:volatile 'refs/remotes/origin/*:refs/heads/' --prune
git push -f remote-url1:volatile '+refs/tags/*:refs/tags/*' --prune