I have local machine (A), testing server (B) and repository server (C).
I have following workflow:
- Code something on A
- Mirror changes to test machine B
- If it works well commit from B to C
For now, I use rsync for mirroring, but since repository grows it takes some time (~10 sec) to get file list from B. I want to use Git instead of rsync, because it would be much faster and I would have local history along with repository C.
The problem is I haven’t found any way to do live-mirroring with git. I can do
git add . && git commit -m "mirroring" && git push
on local machine, but what about server?
Is cronjob for every few second
git checkout | awk '{print $2;}' | git checkout
a right way?
P. S.: I new in git and maybe there is more appropriate tools for this job.
Live-mirroring with Git can be done via git hooks.
You can set up
updatehook, which can execute actions rigt after a branch was updated. Set this hook up at server B. The hook will be launched atB‘s site each time you push changes to it. Inside this hook, you may just push changes forward toC(for which you should create a remote). The hook would look like this:So each time you update
B,Cwill also get updated. If something failed during that push, you’ll see the relevant messages in console, and your initial push won’t succeed. That’s what’s called “mirroring”, isn’t it?