title: Using git-flow in a multi-stage deployment
body: <p>Drawing a blank with finalizing my deploy scheme here. After posting this question: <a href="https://stackoverflow.com/questions/5835997/migrating-a-production-site-with-no-vcs-at-all-to-git">Migrating a production site with no VCS at all to Git</a>, I've got the gist of deploying to a local repo down.</p>
  
  <p>My local development server has a git-flow repository on it that I can push to and it will update an external worktree.</p>
  
  <p>I have my repo set up with git-flow and here's what my origin remote looks like: </p>
  
  <pre><code>$ git remote show origin
  * remote origin
    Fetch URL: ssh://user@host/var/git/dev/repo.git
    Push  URL: ssh://user@host/var/git/dev/repo.git
    HEAD branch (remote HEAD is ambiguous, may be one of the following):
      develop
      master
    Remote branches:
      develop tracked
      master  tracked
    Local branch configured for 'git pull':
      master merges with remote master
    Local refs configured for 'git push':
      develop pushes to develop (up to date)
      master  pushes to master  (up to date)
  </code></pre>
  
  <p>What I attempted to do, was set up 2 pseudo-environments. One for staging and one for production. I want to have them behave as follows:</p>
  
  <pre><code>git push staging #pushes to remote staging repo with a post-receive hook "git checkout develop -f"
  
  git push production #pushes to remote production repo with a post-receive hook "git checkout master -f"
  </code></pre>
  
  <p>This way, we can develop locally and push to our little internal development server and have all the history. Then when we're clear for staging/production, we just push out the appropriate branches.</p>
  
  <p>I tried creating bare repos with separate work trees like I did with the development server (see my link at the beginning of the post), and simply did:</p>
  
  <pre><code>git push staging develop
  git push production master
  </code></pre>
  
  <p>And here are the remotes, respectively:</p>
  
  <pre><code>$ git remote show staging
  * remote staging
    Fetch URL: ssh://user@host/var/git/dev/staging.git
    Push  URL: ssh://user@host/var/git/dev/staging.git
    HEAD branch: develop
    Remote branch:
      develop tracked
    Local ref configured for 'git push':
      develop pushes to develop (up to date)
  
  $ git remote show production
  * remote produdction
    Fetch URL: ssh://user@host/var/git/dev/production.git
    Push  URL: ssh://user@host/var/git/dev/production.git
    HEAD branch: master
    Remote branch:
      master tracked
    Local ref configured for 'git push':
      master pushes to master (up to date)
  </code></pre>
  
  <p>So, in theory, we can use git-flow internally, track the develop branch and push it out for other departments to view/QA. Then we can do our releasing internally, and push the changes to staging and then simply push the master branch to production.</p>
  
  <p>I guess my question is - am I going about this the right way? I am a real novice when it comes to git and git-flow. I've pored over all the resources available and this is the best I could come up with so far.</p>
  
  <p>Any insights from folks who are using git-flow in multi-stage deployment would be greatly appreciated. </p>