I've got repository A on a server on network 1 and repository B on a different server on network 2. The hold the same codebase, but different people are contributing to each one. There is no direct access between network 1 and 2 (enterprise security rules - don't ask), but it is possible to manually move files between networks (EG, VPN into network 2 and access to files on the hard drive of my machine).
What I seek to do is script out all the changes made to repository A in a given day, and then import them to repository B, and vice versa. (I'd manually resolve conflicts). How should I go about doing this?
Any help would be much appreciated!
Community moderators have prevented the ability to post new answers.
Hi again Huw,
Sorry, when I wrote my previous answer I was under the impression that you could VPN into each network from the same box. Patches will work as you described, but might be a bit cumbersome if the volume of changes is large. You might consider git bundles as an alternative.
cheers,
Tim
Thanks for your reply. I can't access repoA Url and repoB Url on the same computer due to network security restrictions. For anyone with the same problem a work-around is:
Commit to repo A as normal. When you want to move changes into Repo B on another network, do:
git format-patch --summary-<n> --subject-prefix="[PATCH] Branch: <branch name>"
Where n is the last n commits on repo A, and <branch name> is your branch name.
Move the patch file onto a machine that can see network B.
Check the patch and add it to Repo B:
git apply --check <path to patch and filename>
git am <path to patch and filename>
Push changes
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Huw,
Git is actually really good at doing all the heavy lifting in this kind of workflow for you! Here's how I'd do it.
Clone repository A onto your local computer:
git clone <repoA_url>
Then cd to your clone directory and add repository B as a remote:
git remote add repob <repoB_url>
Then when you're ready to sync, update your clone with any new changes from repository A:
git pull origin *:*
Then pull down any new changes from repository B:
git pull repob *:*
Any branches that have diverged in history will show up as a rejected update in the console output, e.g.:
! [rejected] master -> master (non-fast-forward)
Depending on your branching strategy, this will usually only be one or two branches, e.g. master and develop. You can manually merge them at this point, resolving any conflicts. E.g.
git checkout master git merge repob/master
Then you can push all of your branches and tags back up to repository A and B:
git push origin --all git push origin --tags git push repob --all git push repob --tags
Hope this helps!
cheers,
Tim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.