I’m trying to work out a method to port code between two disconnected environments using Git. Code will be edited in both locations before being merged together for releases. Ideally, I’d like to export the “master” branch from one location (A) and then add it to a repository in another location (B) as a “remote-dev” branch. After that, changes in the “remote-dev” branch can be merged into the “master” branch of the second location (B) for release preparation. This transfer would be repeated periodically so the desire is to be able to overlay “remote-dev” with updated code and have the history still preserved and still allow for merges up to “master” without having to remerge code that was previously merged. Also, only the “master” branch should be brought over from environment A as there will be many other branches with active development present that should not be copied.
The goal here is for an automated, repeatable process. I’d like to be able to setup a batch file which does the export of a branch in environment A each night. Someone will copy the files over to environment B and place them in a drop-off location. Another batch file will be scheduled to run in environment B which picks up the files and merges them into the destination repository in environment B.
There are good details in both "How do you merge two Git repositories?" and "How to import existing Git repository into another?". Unfortunately, neither seems to cover the repeatability aspect that I’m looking for.
Both discussions mention “git merge” and “git subtree add” as possible solutions here for grating a branch into a different repository. However, neither covers the repeatability aspect of it. Would it be necessary to delete the destination branch before re-merging or can the imported branch be merged over the top of a previous import? Also, should any special steps be taken to export out only the “master” branch from environment A to avoid any excess data being moved between environments?
Has anyone tried something like this with success?