HowTo keep in sync your git repository for redmine
Version 7 (Philippe Creux, 2011-06-21 18:58)
| 1 | 1 | Thomas Lecavelier | h1. HowTo keep in sync your git repository for redmine |
|---|---|---|---|
| 2 | 1 | Thomas Lecavelier | |
| 3 | 3 | Eddie Ringle | Here is a HowTo written by Farzy ("Farzad FARID":http://www.pragmatic-source.com/) that explains how to keep two git repositories syncronized |
| 4 | 1 | Thomas Lecavelier | |
| 5 | 1 | Thomas Lecavelier | * "Automatic synchronization 2 git repositories [en]":http://www.pragmatic-source.com/en/opensource/tips/automatic-synchronization-2-git-repositories |
| 6 | 1 | Thomas Lecavelier | * "Synchronisation automatique de deux référentiels git [fr]":http://www.pragmatic-source.com/fr/opensource/tips/synchronisation-automatique-de-deux-referentiels-git |
| 7 | 2 | Jim Mulholland | |
| 8 | 3 | Eddie Ringle | *Summary Of Above Blog Posts* |
| 9 | 2 | Jim Mulholland | |
| 10 | 2 | Jim Mulholland | _In the below example, "git_user" and "project.git" should be modified for your GitHub project_ |
| 11 | 2 | Jim Mulholland | <pre> |
| 12 | 2 | Jim Mulholland | git clone --bare git@github.com:git_user/project.git project.git |
| 13 | 2 | Jim Mulholland | cd project.git |
| 14 | 2 | Jim Mulholland | git remote add origin git@github.com:git_user/project.git |
| 15 | 2 | Jim Mulholland | git fetch -v |
| 16 | 2 | Jim Mulholland | git fetch origin |
| 17 | 2 | Jim Mulholland | git reset --soft refs/remotes/origin/master |
| 18 | 2 | Jim Mulholland | </pre> |
| 19 | 2 | Jim Mulholland | |
| 20 | 2 | Jim Mulholland | _In this cron script, "app" is the owner of the project.git directory_ |
| 21 | 2 | Jim Mulholland | <pre> |
| 22 | 2 | Jim Mulholland | sudo vi /etc/cron.d/sync_git_repos |
| 23 | 2 | Jim Mulholland | # One-way synchronization of a local and remote bare Git repository. |
| 24 | 2 | Jim Mulholland | # Repeat this line for each repository. |
| 25 | 1 | Thomas Lecavelier | */5 * * * * app cd /path/to/project.git && git fetch origin && git reset --soft refs/remotes/origin/master > /dev/null |
| 26 | 2 | Jim Mulholland | </pre> |
| 27 | 3 | Eddie Ringle | _*/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.)_ |
| 28 | 4 | Alexey Trofimenko | |
| 29 | 6 | Alexey Trofimenko | UPDATE: when using sufficiently recent git (>=1.6.0) |
| 30 | 4 | Alexey Trofimenko | |
| 31 | 4 | Alexey Trofimenko | <pre> |
| 32 | 4 | Alexey Trofimenko | git clone --mirror git@github.com:git_user/project.git |
| 33 | 4 | Alexey Trofimenko | </pre> |
| 34 | 4 | Alexey Trofimenko | |
| 35 | 4 | Alexey Trofimenko | then install a crontask |
| 36 | 1 | Thomas Lecavelier | <pre> |
| 37 | 6 | Alexey Trofimenko | sudo vi /etc/cron.d/sync_git_repos |
| 38 | 7 | Philippe Creux | */5 * * * * app cd /path/to/project.git && git fetch -q --all |
| 39 | 4 | Alexey Trofimenko | </pre> |