Git workflow/Deployment

deployment, git, initialization, installation, workflow

Solution

I recently moved my team from SVN to Git too and we have the same setup of 3 servers, prod, stg and dev..

For the migration process, first `sudo apt-get install git-svn` and then..

$ git svn clone [subversion_repository_url] /path/to/git/repository
$ cd /path/to/git/repository
$ git remote add origin [gir_repo_url]
$ git push origin master

For Workflow,

This link titled "A successful Git branching model" was immensely useful. It entails how to go about using a 'Production - Staging - Dev' type of workflow for a team.

With regards to Deployment:

On each of the servers, what we do is, Each of the servers have the git repo someplace on the filesystem. To deploy, I archive the respective branch I need to deploy and unzip it into the /srv/www/ folder..

For example, on Prod, to deploy the master branch,

sudo git archive --format zip --output output.zip master -0

^The 'master' indicates the branch you want zipped up. This excludes the .git folder. And then to unzip inside the /srv/www/ folder, `sudo unzip output.zip -d /srv/www/app/` This is the equivalent of an `svn export` command.

For the Staging server we usually checkout one of the Release branches or the Dev branches..

And for the Dev server, we checkout whichever feature-branch we need to perform testing on.

Problem

I'm new to Git and trying to move my website away from SVN to GIT for version control and also deployment. I've got a number of developers who will work on their local machine and I've got 3 servers, 'development', 'staging' and 'production'. I've been reading books and watching videos of how Git works so I think I'm pretty familiar with it now as in adding, committing etc, however I need advice on the workflow and deployment. The first thing I need to know is where to initialize the GIT repository. Does it need to be on the 'production' server and then I clone it on 'staging' and 'development' and each developer also clones it to their local machine? Secondly, should each server have it's own branch? I.e 'development' will have a 'development' branch, 'staging' will have a 'staging' branch and 'production' will have a 'production' branch? Thanks

Original source

Related problems