HowTo keep in sync your git repository for redmine

With sufficiently recent git (>=1.6.0)

In the below examples, "git_user" and "project.git" should be modified for your GitHub project

Set up a (bare) mirror of the source repository

git clone --mirror

to fetch the changes

cd project.git
git fetch -q --all -p

make fetching automatic by installing a crontask

sudo vi /etc/cron.d/sync_git_repos
*/5 * * * * app cd /path/to/project.git && git fetch -q --all -p

*/5 in the last line defines the minute at which the synchronization takes place, for example, */2 would cause the sychronization to take place every two minutes. */5 causes the synchronization to take place on minutes divisible by 5 (5, 10, 15, etc.)

With older git

Here is a HowTo written by Farzy (Farzad FARID) that explains how to keep two git repositories syncronized

Summary Of Above Blog Posts

git clone --bare project.git
cd project.git
git remote add origin
git fetch -v
git fetch origin
git reset --soft refs/remotes/origin/master 

In this cron script, "app" is the owner of the project.git directory

sudo vi /etc/cron.d/sync_git_repos
# One-way synchronization of a local and remote bare Git repository.
# Repeat this line for each repository.
*/5 * * * * app cd /path/to/project.git && git fetch origin && git reset --soft refs/remotes/origin/master > /dev/null

Updated by Ulf Unger over 9 years ago · 12 revisions