HowTo keep in sync your git repository for redmine » History » Version 12
Ulf Unger, 2014-03-25 20:45
Added "-p" to git commands - in this case remotely deleted branches will get deleted on the "redmine read only copy" too.
1 | 1 | Thomas Lecavelier | h1. HowTo keep in sync your git repository for redmine |
---|---|---|---|
2 | |||
3 | 8 | Joon Ro | h2. With sufficiently recent git (>=1.6.0) |
4 | |||
5 | _In the below examples, "git_user" and "project.git" should be modified for your GitHub project_ |
||
6 | 9 | Joon Ro | |
7 | 10 | Joon Ro | Set up a (bare) mirror of the source repository |
8 | 8 | Joon Ro | <pre> |
9 | git clone --mirror git@github.com:git_user/project.git |
||
10 | </pre> |
||
11 | 11 | Joon Ro | |
12 | to fetch the changes |
||
13 | <pre> |
||
14 | cd project.git |
||
15 | 12 | Ulf Unger | git fetch -q --all -p |
16 | 11 | Joon Ro | </pre> |
17 | 1 | Thomas Lecavelier | |
18 | 11 | Joon Ro | make fetching automatic by installing a crontask |
19 | 8 | Joon Ro | <pre> |
20 | sudo vi /etc/cron.d/sync_git_repos |
||
21 | 12 | Ulf Unger | */5 * * * * app cd /path/to/project.git && git fetch -q --all -p |
22 | 8 | Joon Ro | </pre> |
23 | _*/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.)_ |
||
24 | |||
25 | h2. With older git |
||
26 | |||
27 | 1 | Thomas Lecavelier | Here is a HowTo written by Farzy ("Farzad FARID":http://www.pragmatic-source.com/) that explains how to keep two git repositories syncronized |
28 | |||
29 | * "Automatic synchronization 2 git repositories [en]":http://www.pragmatic-source.com/en/opensource/tips/automatic-synchronization-2-git-repositories |
||
30 | 2 | Jim Mulholland | * "Synchronisation automatique de deux référentiels git [fr]":http://www.pragmatic-source.com/fr/opensource/tips/synchronisation-automatique-de-deux-referentiels-git |
31 | 3 | Eddie Ringle | |
32 | 2 | Jim Mulholland | *Summary Of Above Blog Posts* |
33 | |||
34 | <pre> |
||
35 | 1 | Thomas Lecavelier | git clone --bare git@github.com:git_user/project.git project.git |
36 | 2 | Jim Mulholland | cd project.git |
37 | 3 | Eddie Ringle | git remote add origin git@github.com:git_user/project.git |
38 | 4 | Alexey Trofimenko | git fetch -v |
39 | 6 | Alexey Trofimenko | git fetch origin |
40 | 4 | Alexey Trofimenko | git reset --soft refs/remotes/origin/master |
41 | </pre> |
||
42 | |||
43 | _In this cron script, "app" is the owner of the project.git directory_ |
||
44 | <pre> |
||
45 | sudo vi /etc/cron.d/sync_git_repos |
||
46 | 1 | Thomas Lecavelier | # One-way synchronization of a local and remote bare Git repository. |
47 | 6 | Alexey Trofimenko | # Repeat this line for each repository. |
48 | 7 | Philippe Creux | */5 * * * * app cd /path/to/project.git && git fetch origin && git reset --soft refs/remotes/origin/master > /dev/null |
49 | 4 | Alexey Trofimenko | </pre> |