Skip to content
dephraser edited this page Feb 10, 2012 · 7 revisions

Branching

  • The master branch is treated as sacred, we will only merge into that when we have something that works for milestones
  • The develop branch is the main working branch
  • The feature branches is where the features being worked on from the issues list will be worked on and then merged back into the develop branch when it is complete.

branching model

Adding files and commiting

Adding files

If you create a new file or change an existing one, you have to add it so git knows about it. This is the git add command. So if you make a new file herp.java and edited derp.java:

$ git add herp.java derp.java

You can review the status of git, which files are staged for commit, which files have been changed but are not staged for commit etc using:

$ git status

Commiting files

When you are at a natural break, like finished a method, do a commit

$ git commit

If you are feeling lazy and just want to put a quick commit:

$ git commit -m "derp herp"

If you are feeling super lazy and have been editing a lot of files you want to commit (which is bad form):

$ git commit -a -m "derpity derp"

The -a automatically picks up any changed files


Feature branches

May branch from: develop
Must merge back into: develop
Naming: try to reference the issue you are working on

Creating a feature branch

When starting work on a new feature, branch off from the develop branch.

$ git checkout -b myfeature develop
Switched to branch 'myfeature'

Now do the work to get the feature working

Adding a branch to github

If a few people are working on the same issue then you will need to add the branch to the github server

$ git push origin myfeature

This will allow other speak to switch to that branch after a git pull

Merging a finished feature back in

When a new feature is finished, we need to merge it into the develop branch

$ git checkout 'develop' Switched to branch develop

$ git pull origin develop

$ git merge --no-ff myfeature
Updating ea1b82a..05e9557
(Summary of changes)

$ git branch -d myfeature
Deleted branch myfeature (was 05e9557).

$ git push origin develop

  • The --no-ff option just forces it to generate a new commit for the merge instead of dragging the old commits from the branch which are just a pain in the butt to fix

###Completely removing a branch (including from github)

$ git branch -d branchname

$ git push origin :branchname

###Switching to someone elses branch

Before switching you should make sure that your local repo knows about the branches on the server. To do this run:

$ git fetch

Then switch branch as before using:

$ git checkout branchname

Milestones

When a milestone is taken

I (David) will take a branch off the develop branch once all the issues for the milestone have been resolved.

$ git checkout master
Switched to branch 'master'
$ git merge --no-ff develop
Merge made by recursive.
(Summary of changes)
$ git tag -a milestone1

Clone this wiki locally