Skip to content

4.Git branching model

FWAJL edited this page Apr 22, 2015 · 11 revisions

Intro

Read this before you start any coding: http://nvie.com/posts/a-successful-git-branching-model/

Merging dev to/from feature branches

The DEV branch is merged to the feature branches so they are kept up to date as often as possible.

Also the Feature branches are merged to Dev when code is ready to be staged and released.

IMPORTANT: don't forget to do a git pull before you start any work. An update may exist.

Steps for a feature branch

Make sure to sure to be on the dev branch first

git checkout dev

To create the feature branch from the dev branch, please follow the work flow below:

git checkout -b feature_[task designation or milestone title] dev (create a branch from the branch dev)

Otherwise, run the following:

git push --set-upstream origin feature_branch

If you are just retrieving the existing branch, you need to do this:

git checkout -t origin/feature_[task designation or milestone title]

After that, just do git push and you are good.

Do your coding and when you are done, follow the usual git commit flow:

git add -A

git commit -m "Issue #ID" -m "- Comment #1" -m "- Comment #2" -m ... NB: the "-" preceding each comment creates a line break to view them more clearly afterwards.

git push (login required).

If you are working with someone else on that task or milestone, make sure to:

git pull (retrieve updates if any)

Steps to merge the feature branch to dev branch or any other feature or bug branch

git checkout branch_to_copy_updates_to

git merge --no-ff feature_[task designation or milestone title]

git push origin branch_to_copy_updates_to

Steps to delete a branch

Read this [source] (http://makandracards.com/makandra/621-git-delete-a-branch-local-or-remote)

git branch -d feature_[task designation or milestone title] (deletes the local branch)

git push origin --delete feature_[task designation or milestone title] (deletes the remote branch in git version 1.7)