Contributor Git Instructions

This page documents how to develop OSEHRA software through Git. See our repository page for repository URLs and mirrors.

Setup

Before you begin, perform initial setup:

  1. Register OSEHRA Code Review Access
  2. Clone the repository
    $ git clone git://code.osehra.org/VistA.git
  3. Run the developer setup script to prepare your work tree and create Git command aliases used below:
    $ Scripts/SetupForDevelopment.sh

    Enter the Gerrit user name registered above when prompted.

Workflow

Our collaboration workflow, based on topic branches, consists of three main steps:

  1. Local Development
    1. Update
    2. Create a Topic
  2. Code Review
    1. Share a Topic (requires Code Review Access)
    2. Revise a Topic
  3. Integrate Changes
    1. Merge a Topic (requires authorization by OSEHRA)
    2. Delete a Topic

Update

Update your local master branch:

$ git checkout master
$ git pull

Create a Topic

All new work must be committed on topic branches. Name topics like you might name functions: concise but precise. A reader should have a general idea of the feature or fix to be developed given just the branch name.

To start a new topic branch:

$ git fetch origin
$ git checkout -b my-topic origin/master

Edit files and create commits (repeat as needed):

$ edit file1 file2 file3
$ git add file1 file2 file3
$ git commit

Share a Topic

When a topic is ready for review and possible inclusion, share it by pushing to Gerrit. Be sure you have registered for Code Review Access.

Checkout the topic if it is not your current branch:

$ git checkout my-topic

Check what commits will be pushed to Gerrit for review:

$ git prepush

Push commits in your topic branch for review by the community:

$ git gerrit-push

Find your change in the OSEHRA Gerrit instance and add reviewers.

Revise a Topic

If a topic is approved during Gerrit review, skip to the next step. Otherwise, revise the topic and push it back to Gerrit for another review.

Checkout the topic if it is not your current branch:

$ git checkout my-topic

To revise the 3rd commit back on the topic:

$ git rebase -i HEAD~3

(Substitute the correct number of commits back, as low as 1.)

Follow Git's interactive instructions. Preserve the Change-Id: line at the bottom of each commit message.

Return to the previous step to share the revised topic.

Merge a Topic

After a topic has been reviewed and approved in Gerrit it may be submitted to the upstream repository.

Only developers authorized by OSEHRA may perform this step.

Use the "Submit Patch Set" button that appears on the change review page.

Delete a Topic

After a topic has been merged upstream, delete your local branch for the topic.

Checkout and update the master branch:

$ git checkout master
$ git pull

Delete the local topic branch:

$ git branch -d my-topic

The branch -d command works only when the topic branch has been correctly merged. Use -D instead of -d to force the deletion of an unmerged topic branch (warning - you could lose commits).