Git Branching

            I like to use are two kinds of branches, features (aka enhancement / story) and issues. A single feature can encapsulate a group of enhancements or even a sprint. We can be flexible here as creating too many branches will slow us down. An issue is a bug, a configuration change or some kind of task that involves a code change.

The naming convention is:-
feature-name e.g. feature-add-currency-prices
issue-name e.g. issue-prices-not-appearing

Seeing which Branches are Available

git branch
Or for remote branches not in your repository
git branch -a

Creating a Branch

To create a branch on an project that you have previously cloned and as a side effect also switch to the branch
git checkout -b feature-add-currency-prices
Make some changes, commit them in the usual way. Then push to the repository and add the branch to the repository so that others can see it
git push -u origin feature-add-currency-prices
And simply do
git push

Using an Existing Branch

To switch to an existing branch first make sure you have the latest repo which includes the branch
git pull
Then checkout the branch and switch to it
git checkout feature-add-currency-prices
Make git changes and commit in the usual way and then when its time to push
git push -u origin feature-add-currency-prices
After that git remembers your branch so you can simply type
git push

Merging to Master

Finally merge to master
git checkout master
git pull
git pull origin feature-add-currency-prices
git push origin master

Merging changes from Master to a branch

git checkout master
git pull
git checkout feature-add-currency-prices
git pull origin feature-add-currency-prices
git merge master
-- there maybe conflicts at this point
git status
-- after all conflicts are resolved
git push origin feature-add-currency-prices


Eclipse didn’t do a good job of branching but once the branch is setup it does recognise the branch and can be used for commit and after the first manual push.


To tag the master after a successful test to say v-0.2.6

git tag -a v-0.2.6 -m 'v-0.2.6'
git push origin v-0.2.6


To see what commits are waiting to be pushed
git log --branches --not --remotes
For a list of files to be pushed, run
git diff --stat --cached origin/master
To delete a branch
git branch -d branch_name
To remove from origin
git push origin :branch_name