Sync from local git folder to remote folder

281 views Asked by At

I want to know is possible to sync from local git repository to remote server.

  1. I have git repository in our server on LAN
  2. I have a git repository in Remote server like Godaddy or Amazon.

Is it possible to sync changes files from LAN git repository server to remote server repository for get updated files from any where? (Outside office)

Please provide any methods are available.

1

There are 1 answers

1
Romain Warnan On

If you have contrĂ´le over the remote repository on your LAN, you could use a post-receive hook that will push to the external repo each time you push to the LAN repo :

First ssh to the server on your LAN and cd into the remote bare repo (eg : your-repo.git/). Then create an executable file named post-receive in hooks/ folder and paste this content inside :

#!/bin/bash
echo 'Running post-receive hook'
git push ssh://godaddy...amazon...github..whatever/your-repo.git --all
git ush ssh://godaddy...amazon...github..whatever/your-repo.git --tags

That way, the external remote repo will always be in sync with the LAN remote repo.

I can provide further explanations if in addition you want to push changes directly into the external remote repo.