Skip to content

Instantly share code, notes, and snippets.

@jhsu
Created January 22, 2010 15:48
Show Gist options
  • Save jhsu/283863 to your computer and use it in GitHub Desktop.
Save jhsu/283863 to your computer and use it in GitHub Desktop.
Git Workflow Blueprint

based off of Vincent Driessen's workflow (PDF)

Naming Convention

Branch Names

master
develop
release-$version
hotfix-$version
ticket-$number

New Feature (off of 'develop' branch)

Start

git checkout develop; git pull origin develop
git checkout -b $feature

Finish

git checkout develop; git pull origin develop
git merge --no-ff $feature

or using a git alias

git config --global alias.join = merge --no-ff
git join $feature

Release Branches (off of 'develop' branch)

This is for bug fixes and meta data (i.e. version bumps and changelog updates) in preparation for deployment. This branch should be titled "release-*" such as "release-1.0" and should be created from 'develop' branch when it is at an almost ready state.

IMPORTANT Any feature branches for post release need to wait before merging back into develop.

Start

git checkout develop; git pull origin develop
# if there's a specific commit you want to branch off from
git checkout 529b8s

git checkout -b release-$version

Finish

merge to master (production ready / stable)

git checkout master
git merge --no-ff release-$version
git tag $version

merge back to develop

git checkout develop; git pull origin develop
git merge --no-ff release-$version

when done

git branch -d release-$version

Hotfix Branches (off of 'master' branch)

Start

git checkout master; git pull origin master
git checkout -b hotfix-$version 

Finish

merge to master:

	git checkout master; git pull origin master
	git merge --no-ff hotfix-$version
	git tag $version

if no release branch, merge to develop

	git checkout develop; git pull origin develop
	git merge --no-ff hotfix-$version

else if release branch, merge to release-$version {

	git checkout release-$version; git pull origin release-$version
	git merge --no-ff hotfix-$version

Functions Needed

ams PROJECT

ams PROJECT should:

  1. update master, update develop

update 'develop' branch

easily update 'develop' branch (git fetch origin/develop)

git stash
working_branch=[current_branch]
git checkout develop; git pull origin develop
git checkout $working_branch
git stash pop

view changes since branch started

git fetch
git log -p $branch..origin/$branch

checkout release branch

git checkout develop; git pull origin develop
git checkout -b release-$version

push release to production

git checkout develop; git pull origin develop
git merge release-$version
git checkout master; git pull origin master
git merge release-$version

merge release changes

Version Bump

bump version to 1.x

bump version to 1.1.x

Oopsies

DANGER

git reset --hard

Destructive. You will lose unstashed / uncommited changes.

Pulling certain commits

git cherry-pick # may need an alias to better handle

Pulling a range of commits

should be able to provide 2 hashes and grab those changes to current branch

example: git pluck $hash1..$hash2 git pluck $hash1 $hash2

Notes

Compression

git gc

Git config

branch="develop"
git config branch.$branch.remote=origin
git config branch.$branch.merge=refs/heads/master

Git diff staged changes

git diff --staged

Terms

index / staging - staging area between your working directory and your repository
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment