my notes online

home tags

Git Daily Usage and Branching Model

08 Jul 2010

What is Git

Git is a distributed revision control system with an emphasis on speed. Git was initially designed and developed by Linus Torvalds for Linux kernel development. Every Git working directory is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server.

The central repository holds two main branches and a number of feature branches:

The feature branches are used to develop new features for the upcoming or a distant future release. When starting development of a feature, the target release in which this feature will be incorporated may well be unknown at that point. The essence of a feature branch is that it exists as long as the feature is in development, but will eventually be merged back into the master branch in order to add the new feature to the upcoming release or discarded in case of a failed experiment.

Creating a feature branch

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

git checkout -b feature_x master

Push feature branch to central repository for sharing

git checkout feature_x
git push origin feature_x

Merge feature into master

Finished features may be merged into the master branch to definitely add them to the upcoming release:

git checkout master
git merge --no-ff --log feature_x
git branch -d feature_x
git push origin master

The --no-ff and --log flags cause the merge to always create a new commit object, even if the merge could be performed with a fast-forward. This avoids losing information about the historical existence of a feature branch and groups together all commits that together added the feature.

Merge features into stable

git checkout -b stable --track origin/stable #only needed once
git pull
git merge --no-ff --log master
git push

Git, Linux, Revision control, and Version control

comments powered by Disqus