HOWTO.gitflow - raynaldmo/HOWTO GitHub Wiki

References

Notes from BuildAModule "Change Management and Version Control" video

Workflow for 1-3 person team

  • Two branches, develop and master
  • Production server stays on master branch and only pulls changes from remote master
  • Team members make code changes on develop branch and push changes to develop branch on remote
  • Team members pull changes from develop branch on remote

Release code

  1. One team member merges develop branch into master branch in their local repo
  2. Tag release
  3. Push changes to master branch on remote
  4. On production server pull changes from master branch on remote

Workflow for 3+ person team

  • Use Gitflow branching model
  • References

http://nvie.com/posts/a-successful-git-branching-model
http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow
https://github.com/nvie/gitflow
GitHub Flow

Gitflow branches

  • Master (PROD) - tested and stable code for production server
  • Hotfix (PROD) - branch for emergency bug fixes
  • Release (TEST) - stable code for staging/test server
  • Develop (INT) - features and bug fixes from all team members
  • Feature (local) - separate track of development before rolling it into main line of development

Release branch cycle

  • create release branch off of develop branch
  • on staging/test site make bug fixes directly on release branch (no new features should be added to a release branch)
  • merge release branch with master branch
  • tag master branch
  • update production site with master
  • merge release branch with develop branch
  • push release branch to remote ?
    CAVEAT: IF RELEASE BRANCH IS DELETED AND NOT PUSHED TO REMOTE SOME DEVELOPERS MAY END UP WITH THE WRONG HISTORY
  • delete release branch
# get current tags
git tag -ln

# create release branch of off develop
git checkout -b release-1.4 develop

# we want to make the release branch available to others
# push branch to our remote repo
git push origin release-1.4

Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/raynaldmo/drupal7-git.git
 * [new branch]      release-1.4 -> release-1.4

# simulate bug fix - we’ll modify assets.module and commit
git commit -a -m “Added step 3 of assets.module (bug fix)

# testing of release branch is done
# merge release branch into master
git checkout master
git merge —no-ff release-1.4

# tag master
git tag 1.4 -a -m “Release of 1.4”

# update production site
# on development site
git push

Counting objects: 15, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (15/15), done.
Writing objects: 100% (15/15), 1.72 KiB | 0 bytes/s, done.
Total 15 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), completed with 1 local objects.
To https://github.com/raynaldmo/drupal7-git.git
   b1db48c..37d92bf  master -> master
   b1db48c..75a09a3  release-1.4 -> release-1.4

# on production site - bring in release-1.4 changes
git pull

# sync tags
# from development site, push tags

 git push origin 1.4

Counting objects: 1, done.
Writing objects: 100% (1/1), 166 bytes | 0 bytes/s, done.
Total 1 (delta 0), reused 0 (delta 0)
To https://github.com/raynaldmo/drupal7-git.git
 * [new tag]         1.4 -> 1.4

# from production site, pull tags
git fetch OR git pull

remote: Counting objects: 1, done.
remote: Total 1 (delta 0), reused 1 (delta 0), pack-reused 0
Unpacking objects: 100% (1/1), done.
From https://github.com/raynaldmo/drupal7-git
 * [new tag]         1.4        -> 1.4
Already up-to-date.

git tag -ln
1.4             Release of 1.4

# merges bug fixes in release-1.4 into develop
git checkout develop
git merge —no-ff release-1.4

# delete release branch from local and remote
git push origin :release-1.4
To https://github.com/raynaldmo/drupal7-git.git
 - [deleted]         release-1.4

git branch -d release-1.4