Skip to content
David Sherrill edited this page Jul 10, 2014 · 8 revisions

Getting Psi4 From Github

Obtaining Psi4 from Github

Private and Public Repositories

If you just wish to get a copy of the code and not to develop with it, you can get the most recent stable release from the downloads page on Sourceforge at http://sourceforge.net/projects/psicode/, or you can get the current snapshot of the code from the public repository on GitHub at psi4/psi4public (see To Get the Code below).

Psi4 is available as both public (psi4/psi4public) and private (psi4/psi4) repositories on GitHub. Most of our development has moved over to the public repository to make it easier for users to follow the latest updates. However, the private repository is still available to hold branches with more sensitive development work that is not ready to be made public.

For Developers Only

If you wish to develop with the code, the first step to accessing the code is to create a GitHub account.

If you just wish to make a few changes independently, feel free to fork the psi4/psi4public repository, make appropriate changes, and issue a pull request.

To become a collaborator of the Psi4 team, please contact one of the primary developers to add you as a collaborator. After you've received e-mail from GitHub notifying you've been added to the repo and are logged in to GitHub, you can proceed with steps below.

To Get the Code

Pick one of the SSH or HTTP routes below, followed by the General section.

SSH

Before you can check out a copy of PSI from Github, you must ensure that your SSH key from the machine you wish to check out PSI to has been registered with your account on Github. Go to account settings, select SSH keys, and paste the SSH key (from $HOME/.ssh/id_rsa.pub) from the machine you're using. (If you don't have this file, run ssh-keygen and accept the defaults to create the needed file.)

To check out a fresh working copy of the repository (if you get a 401 error, check your git --version. It needs to be at least 1.7.10):

>>> git clone git@github.com:psi4/psi4public.git psi4

(The final psi4 tells git to pull over the code into a directory named psi4 instead of one named psi4public; it doesn't particularly matter what your copy of the source is called, but traditionally the developers put it in a directory called psi4.)

If during the first clone or pull operation, you get

Permission denied (publickey).
fatal: The remote end hung up unexpectedly

you will need to generate and/or add a public key to github. See the following for details: https://help.github.com/articles/generating-ssh-keys

HTTP

Alternately, you can use the http interface to github, which avoids dealing with SSH keys and instead uses your username and password for each interaction. To avoid retyping your password, follow the instructions on password caching at https://help.github.com/articles/set-up-git#password-caching .

To check out a fresh working copy of the repository (if you get a 401 error, check your git --version. It needs to be at least 1.7.10):

>>> git clone https://github.com/psi4/psi4public.git psi4

General

If you haven't used git on this computer before, it's worthwhile to set a couple configure lines so you'll appear in the statistics. (git config --list to see what's already set):

>>> git config --global user.name "Your Name Here"
>>> git config --global user.email "your_email@example.com"

Now you can compile psi as usual. Instructions at http://sirius.chem.vt.edu/psi4manual/master/installfile.html .

To update your current copy to include the latest commits:

>>> git pull origin master

In this command origin is a remote identifier that refers to where the repository came from, in this case sirius. master refers to the branch from sirius you want to pull from. Issuing a git pull command will fetch and merge the requested branch into your current branch.

To check in code to the master branch (substitute branch name if not on master), make the commit locally (git's add and commit commands), then execute the following commands. If there are conflicts after the pull command, you'll need to resolve them, add and commit the resolved files, then try the pull and push commands below again.

>>> git pull origin master
>>> git push origin master

It is good practice before pushing commits to make sure the code compiles and passes

>>> make quicktests

Branches

The preferred practice is to leave your master branch to only reflect the current state of the repository on GitHub. That being said, all your local development should reside on a different branch. This branch can reside locally only or can be backed-up to GitHub with git push origin greatcode and git pull origin greatcode. Periodically (if your branch is long-lived) or when you are ready to check in changes, your code will need to be merged into the master branch.

Creating a branch

There are two ways of creating and checking out a new local branch. If a remote branch you want isn't available, you may need to git pull just this once instead of git pull origin master.

>>> git branch greatcode
>>> git checkout greatcode

or

>>> git checkout -b greatcode

Listing local branches

This lists all the local branches in the current source tree. The branch with the * indicates the current branch.:

>>> git branch
  2ndderiv
  cdsalcs
  configure
  dmatrix
  f12
* master
  strategy

Switching branches

In this example I'm switching to the cdsalcs branch in the list above.

>>> git checkout cdsalcs

Deleting branches

Be careful that you do not delete a branch you need!

>>> git branch -d cdsalcs

If the branch you want to delete is not fully merged into either its parent branch, git will complain. To force git to delete the branch:

>>> git branch -D cdsalcs

Merging (Rebasing) Branches

So you're ready to merge in your greatcode branch into the master branch. First make sure master is up-to-date, then move to the greatcode branch:

>>> git checkout master
>>> git pull origin master
>>> git checkout greatcode

Next, make quite sure you're on the greatcode branch:

>>> git status
# On branch greatcode
nothing to commit (working directory clean)

Ensure greatcode has any and all new updates from the master branch:

>>> git rebase master

Resolve any conflicts and compile the code to make sure no bugs have been introduced.

Switch to the master branch and merge greatcode into it.

>>> git checkout master
>>> git merge greatcode

The local master branch now contains greatcode. Add greatcode to the remote repository with the usual:

>>> git pull origin master
>>> git push origin master