Skip to content

Instantly share code, notes, and snippets.

@rodluger
Last active December 18, 2018 19:22
Show Gist options
  • Save rodluger/e231c000d2d0ea9b646cf3186ebf7e81 to your computer and use it in GitHub Desktop.
Save rodluger/e231c000d2d0ea9b646cf3186ebf7e81 to your computer and use it in GitHub Desktop.
vplanet workflow

Working with a public repo and a private repo

We currently have a public vplanet repo and a private vplanet-private repo. Here's what we decided our workflow should look like:

All development is done on the (non-master) branches of vplanet-private and synced to master via pull requests. When a change is ready to be incorporated into the current released version of the code, we go to our local clone of the public vplanet repository and pull from master on vplanet-private to local dev. Then, on the GitHub UI, we issue a pull request for master on vplanet.

Setting up tracking on your local machine

1. Clone both repos:

git clone https://github.com/VirtualPlanetaryLaboratory/vplanet.git
git clone https://github.com/VirtualPlanetaryLaboratory/vplanet-private.git

2. Add a remote to vplanet called private. This is how we will pull from the private repo.

cd vplanet
git remote add private https://github.com/VirtualPlanetaryLaboratory/vplanet-private.git
git config --global merge.ours.driver true

3. Add a remote to vplanet-private called public. This is how we will pull from the public repo.

cd ../vplanet-private
git remote add public https://github.com/VirtualPlanetaryLaboratory/vplanet.git
git config --global merge.ours.driver true

Updating the public repo with new stuff from the private repo

1. Say you've made some changes on the private repo and you're ready to push them over to the public repo. Since the repos aren't forks of each other, we can't issue the pull request directly on the GitHub UI. Instead, we do this locally, by pulling from the private repo to the public dev branch, then push it to GitHub:

cd vplanet
git checkout dev
git pull private master
git push origin dev

2. We can now create a pull request from dev to master via the GitHub UI:

Updating the private repo with new stuff from the public repo

1. Now say someone has issued a pull request for dev on vplanet (the public repo). Once that pull request is accepted, let's go into the private repo and pull over the changes to the dev branch on vplanet-private:

cd vplanet-private
git checkout dev
git pull public dev
git push origin dev

2. We can now create a pull request from dev to master via the GitHub UI:

Attribution

Based on this post and this post.

@rodluger
Copy link
Author

rodluger commented Jul 31, 2018

NOTE: Now that we're using Git LFS, things get a little tricky when pulling LFS files from the private repo to the public repo. This may be a bug in LFS or we may just be pushing it beyond what it's meant to do, but whenever I run git pull private master I get a bunch of errors saying [404] Object does not exist on the server for every single LFS file. My current workaround is to copy the .git/lfs/objects folder from the private repo to the public repo before running git pull private master. Things work as expected in that case.

EDIT: I decided to disable LFS for now.

@rodluger
Copy link
Author

rodluger commented Dec 18, 2018

Suggested merge scripts for public/private changes

vplanet/merge-from-public.sh

BRANCH=$(git branch | grep \* | cut -d ' ' -f2)
if [ $BRANCH == "dev" ]
then
    git pull --no-commit --no-ff private master && \
    git checkout $BRANCH README.md && \
    git checkout $BRANCH docs/developers.rst && \
    git checkout $BRANCH docs/genexamples.py && \
    git checkout $BRANCH .ci/build-docs.sh && \
    git checkout $BRANCH .travis.yml && \
    git commit -m "Merging changes from private branch" && \
    echo "Files changed: " && \
    git diff --name-only HEAD^ && \
    echo "Success! Please push your changes to origin dev and issue a pull request for master." ||
    echo "Merge was not performed."
else
    echo "Merging from private must be done on the dev branch."
fi

vplanet-private/merge-from-private.sh

BRANCH=$(git branch | grep \* | cut -d ' ' -f2)
if [ $BRANCH == "dev" ]
then
    git pull --no-commit --no-ff public master && \
    git checkout $BRANCH README.md && \
    git checkout $BRANCH docs/developers.rst && \
    git checkout $BRANCH docs/genexamples.py && \
    git checkout $BRANCH .ci/build-docs.sh && \
    git checkout $BRANCH .travis.yml && \
    git commit -m "Merging changes from public branch" && \
    echo "Files changed: " && \
    git diff --name-only HEAD^ && \
    echo "Success! Please push your changes to origin dev and issue a pull request for master." ||
    echo "Merge was not performed."
else
    echo "Merging from public must be done on the dev branch."
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment