Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create auto sync between local and remote GIT Server

I am setting up the infrastructure for my project.

We have a remote GIT server at a different location. To avoid network delays we have set up local git server. Now what I intend to do is have my local git server talk to remote Git server so that both are in sync.

The idea is that whenever there is a commit/push in local Git server an automatic trigger must happen that should even push code to remote Git server and vice versa.

So finally at all time we have perfectly synced Git servers and now much faster too. I do not know how to achieve this, was wondering if something with hooks can be done, but I have no ideas.

like image 450
nishat Avatar asked Nov 18 '25 13:11

nishat


1 Answers

As others pointed out in comments, git is pretty efficient about what it sends over the network. Unless you are versioning large binary files, pushing to a remote server over a slow internet connection won't be an issue. However, if you have a large repository the initial clone may take a long time. To improve that experience you could use a local mirror that people can clone from and then repoint origin at the main repository. There's more information here

  • How to properly mirror a git repository
  • What's the difference between git clone --mirror and git clone --bare
  • GIT hook post-receive and remote repository git pull. The title of this one is a little deceiving, but the first part of the answer talks about what you are looking for.
like image 151
Roman Avatar answered Nov 21 '25 04:11

Roman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!