git-sync is an automated synchronization of two remote Git repositories with auto conflict solving.
Scenarios of usage
- Auto synchronization of remote Git-repositories.
- Sharing of a repository with limited internet access with your partners.
- Keeping of repositories neat and sane between customers and clients.
Run and play
If you will run git-sync without a parameter, then a test environment will be created.
You will get two remote and two local interconnected repositories on your machine.
How it works
Imagine, there are two remote repositories. Each repository is a separate side.
You agreed that
- the first repository owns the prefix foo-
- the second repository owns the prefix bar/
- (the names are arbitrary)
Only branches with such the prefixes will be synchronized and visible on both sides.
Conflicts may occur only if your merge or commit to another side.
The prefix owner will win in case of any conflicting git-commits. Commits of a loser will be rejected, but he just has to repeat his commits again from his local repository after a Git update.
The package is prepared, but does not include conflict informing. For this reason, you can ask your another side to perform git-merging from your branch into their. Or just recheck your action after running of git-sync and repeat them if needed.
For now, Git-tags are excluded from synchronization.
Why is everything done so? - This is a proven and working solution. But I am open for ideas.
Why do not synchronize everything at once? - You will spend significant resources to cover this and make everything professional.
Is it possible to synchronize all branches and tags? - Yes. I have another solutions and ideas. No one is interested.
Why do not sync Git-tags? - This is disabled because some popular Git-servers block deletion of tags.
I warned you
Most of the following sections describe technical details.
if you are technically savvy, I expect you will complete everything from one day to one week. Depends on your situation and needs.
The only thing I want to say. This is really working and live solution.
I am waiting for your notes and wish you luck.
Wish to pay for a box?
If you are not ready to spend your time, ask me to do it for you.
I am offering a complete package that includes
- Working solution
- One year support
- Automated backups of your repositories
- Notifications about conflict solving or branch deletion
- reasonable customizations
Contact me at it3xl.com.
- Prevention of an occasional deletion of an entire repository.
- Deletion and creation of branches in the foreign repository.
- Auto conflict resolving by Convention over Git (non-fast-forward branch conflicts).
- Recreation of the synchronization from any position and from scratch.
- Failover & auto recovery of synchronization is supported. Especially for network troubles.
- Solution is applied per-repository (vs per-server)
- Synchronization of the Git-tags was removed because GitLab loves to block tag's deletion.
- Single non-bare Git repository is used for the synchronization.
- You can attach some your automations and notify somehow about conflict solving or about any branch deletion.
My glossary related to the topic.
How to Use
You need to describe the prefixes and simple details of your real remote repositories in a simple config-file.
Create the same file as your_repo_some_name.sh and put it next to it.
Run the git-sync and pass the name of your config file as a parameter.
Run git-sync so periodically, better once in a minute.
That's all. You may work and forget about git-sync.
In the case of any synchronization interruption the git-sync will do everything right.
Use any *nix or Window machine.
For *nix users - update you bash and awk to any modern version
Tune any automation to invocate git-sync periodically - crons, schedulers, etc.
Run in a console
bash git-sync.sh your_file_with_project_settings.sh
Repeat this invocation when you want to synchronize your remote repositories.