git workflow the simple guide

by Carlo DiLorenzo
credits to @tfnico, @fhd and Namics

Frontify - Collaboration for Web Designers & Front-End Developers

Historical Branches

This workflow uses two branches to record the history of the project.
Master - Stores the official release history
Develop - Serves as an integration branch for features.

Clone Repo

Each developer should clone central repo with the develop branch to there local machine.
git clone /path/to/repository
git checkout -b develop origin/develop
Everybody now has a local copy of the historical branches set up.

Feature Branches

Uses develop as its parent branch. When feature is complete it gets merged into develop. Features should never interact directly with master.

Begin new features

First create a branch for a features. (make name descriptive)
git checkout -b some-feature develop
Add commits to the feature branch in the usual fashion: edit, stage, commit.
git status
git add .
git commit

Finishes a Feature

Merge into local develop branch and push into central repo.
git pull origin develop
git checkout develop
git merge some-feature
git push
git branch -d some-feature

Release Branches

Fork a release branch off of develop.
-Check for bugs and other release-oriented tasks.
-Once it's ready merged into master.

Prepare a Release

Create new branch from develop branch.
git checkout -b release-0.1 develop
When the release branch is ready to be merge.
git checkout master
git merge release-0.1
git push
git checkout develop
git merge release-0.1
git push
git branch -d release-0.1
Tag the commit for easy reference.
git tag -a 0.1 -m "Initial public release" master
git push --tag

Maintenance Branches

Maintenance or “hotfix” branches are used to quickly patch production releases.
When an end-user discovers a bug fork from master.
git checkout -b issue-#001 master
# Fix the bug
git checkout master
git merge issue-#001
git push
After fixing bug merge the branch back to master.
git checkout develop
git merge issue-#001
git push
git branch -d issue-#001