Privateer Pattern

The aim of the privateer pattern is to be able to develop julia code in a separate branch synchronised over several computers without giving information away to the official github repository. This is a means to be able to develop unpublished algorithms. It should however not become a stable solution as it decreases mergability: Merge every privateer branch back into the master branch as soon as possible.

First you will need a private repository on a server to synchronize over. If you don’t have a private github repo at your disposal, you can also create a “bare repository” on any ssh reachable machine. We will call this repository “privateer”.

Next, on every machine that participates in the pattern, make sure that a git push only pushes the master branch to origin (the github repo). For the following changes to the .git/config a good reference is Refspec. The essence being that reference specifications go like

The plus sign tells Git to update the reference even if it isn’t a fast-forward. <src> is the specification of the reference on the source machine, <dest> on the destination machine. E.g. by default when we pull from a remote repo, we always keep a reference in remotes/machinename for every branch on the remote machine (asserting reachability). This is achieved by

because we want it to always overwrite the local position (+), on the remote machine the path is git/refs/heads/anybranch, and on the local machine the path is .git/refs/remotes/origin/anybranch. Obviously this line has to be in the specifications for [remote "origin"]. While this line – as it is the default – should already exist in your .git/config we now need to add the following line

Note that you can also always specify the refspec on the commandline (even abbreviated) so this only corrects the default behaviour.

Now we need to add the remote “privateer” on every machine.

On one machine we now need to branch for the new feature branch “feature”.

Now the following lines that we add into the .git/config should make sense:

The branch configuration allows a simply git push on the commandline, where the remote is auto-detected from the current branch.

After the initial git push on the first machine and all the adjustments of the configurations on the other machines we can now pull those branches in on those machines with

Don’t forget to

afterwards (while still checked out at master) to reset the master branch to its original position.