Git workflow (Dev>Staging>Live) basic technical questions

Viewed 6734

I'm quite new to Git (and VC for that matter) and I'm struggling a bit to understand the concept behind the Dev>Staging>Live workflow using branches.

I'm trying to apply part of this workflow, that uses dev branches and release branches instead of a fixed staging.

Before trying to use Git, I had the "same" workflow using SVN. But instead of creating branches for each stage, we used separated repositories for it. Now that I'm trying to apply branches, things are getting a bit blurry.

I can understand the idea behind the workflow, but can't get it from a technical point of view.

The steps that I'm following to create it:

Create folders

user:/var/www/$ mkdir dev.example.local
user:/var/www/$ mkdir staging.example.local
user:/var/www/$ mkdir example.local

Init repositories

user:/var/www/example.local$ git init
user:/var/www/example.local$ git remote add origin git@bitbucket.org:user/example.com.git
user:/var/www/example.local$ echo "README" > README
user:/var/www/example.local$ git commit -am "First"
user:/var/www/example.local$ git push origin master

user:/var/www/example.local$ cd ../dev.example.com
user:/var/www/dev.example.local$ git clone git@bitbucket.org:user/example.com.git .
user:/var/www/dev.example.local$ git checkout -b dev
user:/var/www/dev.example.local$ git push origin dev

user:/var/www/dev.example.local$ cd staging.example.com
user:/var/www/staging.example.local$ git clone git@bitbucket.org:user/example.com.git .

Some work on dev branch

user:/var/www/dev.example.local$ echo "New" > newfile
user:/var/www/dev.example.local$ git add .
user:/var/www/dev.example.local$ git commit -am "Some new file"
user:/var/www/dev.example.local$ git push origin dev

When things are ready for a new release

user:/var/www/staging.example.local$ git fetch
user:/var/www/staging.example.local$ git checkout -b release-0.1 dev
user:/var/www/staging.example.local$ git push origin release-0.1

user:/var/www/staging.example.local$ cd ../example.com
user:/var/www/example.local$ git fetch
user:/var/www/example.local$ git merge --no-ff origin/release-0.1
user:/var/www/example.local$ git tag -a "0.1"
user:/var/www/example.local$ git push origin master

user:/var/www/example.local$ cd ../dev.example.com
user:/var/www/example.local$ git merge --no-ff master
user:/var/www/example.local$ git push origin dev

I'm pretty sure I'm not following the correct steps. So, what's the "right way" to:

  • create the dev, staging, live folders and init the git repo in each one of them?
  • checkout/merge new releases?
  • merge from the release to live?
  • create the whole environment?

And:

  • where should I run those git commands? on my local repo? for each one of the stages?

Relevant info:

  • I'm using BitBucket
  • This is for website (Drupal) development
  • My master branch is the live stage
  • There are about 3 developers working at the same time, and each one in a different country
2 Answers
Related