Skip to content
Florencio Balboa Usabiaga edited this page Dec 1, 2016 · 1 revision

Setup public and private branches for the first time

Some steps may not be necessary if the repositories already exist:

  1. Create public repository on gitHub under the organization stochasticHydroTools.

  2. Create private repository on gitHub under the organization stochasticHydroTools. We can use the name convection "public_repository_name-private".

  3. Clone public repository to your machine, e.g.,

    git clone git@github.com:stochasticHydroTools/RigidMultiblobsWall.git

  4. Add private repo to the local copy, e.g.

    git remote add private git@github.com:stochasticHydroTools/RigidMultiblobsWall-private.git

    This allows us to push changes to the public and the private repository.

  5. Create a branch "next" from the master branch in the public repository and push to the private repo. We can use next like the stable private branch and merge all
    the private changes there. Use the commands:

    git checkout master

    git checkout -b next

    git push -u private next

    note that we are pushing to the private repo with -u private.

Use public and private branches

Some steps may not be necessary:

  1. Clone public repository, e.g.

    git clone git@github.com:stochasticHydroTools/RigidMultiblobsWall.git

  2. Add private repo to the local copy, e.g.

    git remote add private git@github.com:stochasticHydroTools/RigidMultiblobsWall-private.git

  3. Checkout branch "next" from the private repo

    git checkout next

  4. Create developing branch and push to the private repo

    git checkout -b dev

    git push -u private dev

    note that we are pushing to the private repo with -u private.

  5. Merge dev branch to next. DO NOT MERGE WITH MASTER, this way we keep things private.

    git checkout next

    git merge dev

    Solve merging conflicts, commit and then push changes:

    git push private next

  6. To make private features public merge branch next with master and push to the public repository. Use the flag --squash to keep the private history hidden from
    the public repository.

    git checkout master

    git merge --squash next

    Solve merging conflicts, commit and push

    git push origin master

    Of course, we can still create public branches, e.g.

    git checkout -b dev-public

    git push -u origin dev-public

    Note that "origin" is the default name of git repositories, in our case it is the public repository, and merges can be done between any two branches public or p
    rivate not just next and master.