Eric Guo's blog.cloud-mes.com

Hoping writing JS, Ruby & Rails and Go article, but fallback to DevOps note

Setup Mirror Between 2 or More Git Server Using Hooks Script

Permalink

First make sure the two server can using ssh to login each other, then add remote mirror to bare git repository.

Add a bare-repository push mirror remote
git remote add --mirror=push cvpgitip01 git@10.11.37.110:repositories/Feng-Wu/demo.git

Add hooks post-commit in bare git repository.

Push the mirror from a post-commit hook
#!/bin/sh
exec git push cvpgitip01 -f --mirror

Git

Comments