Git Management

supahgreg edited this page Jun 5, 2011 · 4 revisions

This page is meant for collaborators and contributors.

General goals

  • Avoid merge commits on master with conflicts
  • issues get closed in branches and those are merged in upon completion.

Before you start working on a issue

If there is not an existing issue for the problem that you want to attempt to solve, then please make one. Then create a branch for the issue off of the master by doing the following:

$ git checkout -b issue-1 master

The above would create a branch called issue-1 from the master branch, see git-checkout and git-branch for more information on creating branches.

Note (for collaborators): If the change you are considering is very small, and very obvious, then don't bother creating an issue, just make the fix and prepend the commit message with bug fix:, minor fix:, or something similar.

Pulling a branch (for collaborators)

Single commits

If the branch you are about to pull is only one commit in length, then:

  • if the commit can be cleanly cherry-picked do so with git cherry-pick -x <sha1> then do a git commit --amend and add Closes #<issue-num> to the start of the commit message.
  • else the commit cannot be cleanly applied skip to the next section on multiple commits.

Multiple commits (branches)

  • If the branch can be cleany merged, then do git checkout master followed by git merge --no-ff issue-<issue-num>
  • Else if the branch cannot be cleanly merged to master then merge master to the branch, handle the conflicts there, then merge the branch into master. This will make certain that all merge commits on master are clean.

Afterward always do a git commit --amend and add Closes #<issue-num> to the start of the commit message.

Remember that you can visualize the network graph with gitk before pushing to be certain things are correct.