I am recently using a remote git server (my own computer), and the server malfunctioned and can't be remotely accessed.
I was wondering if there is a proper way to maintain TWO remote depositories, so that the second depository on my other computer can be automatically used when the first one fails?
My second question is how to automatically (e.g. via a script) to synchronize the primary and backup remote depositories periodically, and how can I change which one is the default/primary depo?
My daily use case is pretty simple, as follows:
git clone user@host:A.git
cd A
(modify code ..)
git add .
git commit -m "..."
git push
git pull ....
So, there is no branching and conflicts is not my concern here. The primary and the backup(s) repos should just be snapshots of the same work at different points of time. Some of them may be lagging behind because of accessibility issues.
P.S. I am not asking the basics of how to set up a (bare) remote depo, and do regular push-pulls using ssh. What I am asking is if there is a way to automatically switch between a primary and a backup repo when one of them fails.
Thanks.
--- EDIT ---
To clarify, my question boils down to this:
Is there a way to setup two remote repositories like a mirroring RAID (disk array), where
a pull
request pulls from the the most up-to-date repo, and a push
request pushes changes to all live mirrors.
If one of the repos went down, and come back again, it will pick up the changes accumulated in other repos.
Note: there is an old post here, which asks a related question. But the answers there did not address the synchronization problem, and what happens when multiple repos become out-of-sync.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…