Skip to content

Instantly share code, notes, and snippets.

@memphys
Created October 2, 2011 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save memphys/1257580 to your computer and use it in GitHub Desktop.
Save memphys/1257580 to your computer and use it in GitHub Desktop.
Git workflows
$ git flow init
$ git flow feature start login
$ git flow feature finish login
$ git flow release start v0.1.0
# Feature branches
$ git checkout -b myfeature develop
$ git checkout develop
$ git merge --no-ff myfeature
$ git branch -d myfeature
$ git push origin develop
# The --no-ff flag causes 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.
# Release branches
$ git checkout -b release-1.2 develop
# changes to bump the version
$ git commit -a -m "Bumped version number to 1.2"
$ git checkout master
$ git merge --no-ff release-1.2
$ git tag -a 1.2
$ git checkout develop
$ git merge --no-ff release-1.2
$ git branch -d release-1.2
# Hotfix branches
$ git checkout -b hotfix-1.2.1 master
# changes to bump the version
$ git commit -a -m "Bumped version number to 1.2.1"
# fix the bug
$ git commit -m "Fixed severe production problem"
$ git checkout master
$ git merge --no-ff hotfix-1.2.1
$ git tag -a 1.2.1
$ git checkout develop
$ git merge --no-ff hotfix-1.2.1
$ git branch -d hotfix-1.2.1
# co = checkout
# st = status
$ git pull
# create feature/bugfix branch, keep master branch clean
$ git co -b branch-name
# http://programming-motherfucker.com/
Programming, Motherfucker!
$ git st
$ git diff
$ git add .
$ git commit -m "Detailed message about changes made"
$ git co master
$ git pull
$ git co branch-name
$ git rebase master
# here you fix conflicts if there are some (in development branch, not in master)
# commit changes again if necessary
#
# if you want to squash smaller commits in development branch
# to one big commit in master
# $ git rebase -i origin/master
$ git co master
$ git merge branch-name
$ git push
$ git pull
# http://programming-motherfucker.com/
Programming, Motherfucker!
# if some problems appear and you need to fix it and push
$ git stash
# Fix the bug, Motherfucker!
$ git commit -a -m "Sector clear. Problem resolved."
$ git push
$ git stash pop
# http://programming-motherfucker.com/
Programming again, Motherfucker!
$ git commit -a -m "Here I describe what I did"
$ git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment