Skip to content

Git Workflow

ndushay edited this page Apr 6, 2012 · 2 revisions

Git Workflow (with command line examples) for working on Hydra Projects

Preface: We want feedback.

This document outlines how we use git on the Hydra project, but we’ve been eyeing up the git-flow tools. We wonder which option presents less of an obstacle for new contributors. If you have an opinion, speak up on the hydra-tech list.

Reference Material/Reading:

Good places to read about git workflows:

You might want to set up your shell prompt to tell you which git branch you’re in.

Creating a Feature Branch then Rebasing, Merging and Cleaning Up

Scenario: You’re working on the HYDRA-333 ticket.

  1. You already have a working copy of hydra-head cloned to your local machine.
  2. Your work is starting from the contents of hydra-head/master

The steps:

  1. Create a feature branch
  2. If necessary, push a copy of the working branch to github
  3. Rebase the feature branch
  4. Merge the finished work into Master
  5. Clean up after yourself

Here’s how to do the right thing with git on the command line. Note: the parts in parentheses indicates which branch you should be on when you run the command. If it doesn’t matter which branch you’re on, this is indicated with (*).

Create your feature branch

cd hydra-head
(master) git checkout -b HYDRA-333

Make changes and commit them to your feature branch like normal.

(HYDRA-333) git add …
(HYDRA-333) git commit …

If necessary, push a copy of the feature branch to github

If you need to share your feature branch, push it to github

(HYDRA-333) git push origin HYDRA-333

Rebase the feature branch

Repeat work until the HYDRA-333 ticket is ready to close, then rebase that work & merge it into the master branch …

(*) git checkout master
(master) git pull origin master
(master) git checkout HYDRA-333 
(HYDRA-333) git rebase master
... walk through the rebase ...

At this point, you should rerun your full test suite to make sure that the rebase did not break anything.

Merge the finished work into Master

If all of the tests pass after the rebase, you’re ready to merge your work into master and push it to github.

(HYDRA-333) git checkout master
(master) git merge HYDRA-333
(master) git push origin master

Clean up after yourself

Now delete the local & remote copies of the feature branch

(master) git branch -d HYDRA-333
(master) git push origin :HYDRA-333

Advanced usage: Running against the freshest version of the hydra-head code from Github

We don’t recommend this for new users or for production applications, but it is very useful during active development.

If you are in a position where you want/need to run your application with the very latest hydra-head code from Github, this is easy to do. Simply update the line in your Gemfile that lists hydra-head as a dependency and enter this instead:

  gem "hydra-head", :git => "git://github.com/projecthydra/hydra-head.git"

After updating the Gemfile, re-run ‘bundle install’.

You can also do this with other gems. For example, if you want to force your app to use the latest active-fedora code from the “HYDRA-721” branch on GitHub, you can put this in your Gemfile:

gem "active-fedora", :git=>'git://github.com/mediashelf/active_fedora.git'
Clone this wiki locally