wiki:Development/git

Developing with git

The master Pyomo repository is the subversion repository hosted at  https://software.sandia.gov/svn/pyomo. That said, developers who want to interact with the main Pyomo repository through git can do so by using git-svn. The simplest way to get started is to use the pyomo_install script to set up Pyomo within a virtual environment:

python pyomo_install --trunk --venv pyomo

As part of the installation, pyomo_install will use Subversion to check out Pyomo and PyUtilib? into the pyomo/src directory. We will then go in and use git svn to replace the Subversion checkouts with local git repositories:

cd pyomo/src
rm -rf pyomo pyutilib
git svn clone https://software.sandia.gov/svn/pyomo --prefix=origin/ -T pyomo/trunk  pyomo
git svn clone https://software.sandia.gov/svn/pyutilib --prefix=origin/ -T pyutilib/trunk  pyutilib

Finally, we will want to configure the new checkouts within the Python virtual environment:

cd pyomo
../../bin/python setup.py develop
cd ../pyutilib
../../bin/python setup.py develop

Getting started with git

An excellent tutorial for getting started with git is available here:  https://www.atlassian.com/git/tutorials/setting-up-a-repository/

Common git workflows

Arguably, the point of git is the use of feature branches. In this case, we would want to do our development on a separate branch from the master branch we use for syncing with the main Subversion repository:

git branch myFeature
git checkout myFeature

Now that we have our feature branch, we will want to keep it up-to-date with the main development. Subversion relies on a linear version history, so to maintain a linear history on our local git repository, we will use rebase instead of merging. In addition, we will strive keep our master as a clean copy of the main Subversion repository. To update our master we will:

git checkout master
git svn rebase

then we can pull the changes over to our feature branch:

git checkout myFeature
git rebase master