Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Move changes from disconnected Stash repositories

huw jeffries August 12, 2014

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!

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
TimP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 29, 2014

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

0 votes
huw jeffries August 28, 2014

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

0 votes
TimP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 12, 2014

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 &lt;repoA_url&gt;

Then cd to your clone directory and add repository B as a remote:

git remote add repob &lt;repoB_url&gt;

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    -&gt; 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

TAGS
AUG Leaders

Atlassian Community Events