Should You Use Git Branches or Separate Repositories? – Version Control Workflows

gitversion controlworkflows

So I have talked my employer into finally jumping on version control…up until now my experience with git has been for personal projects and freelance work where everything is on one server, or small scripts…so, this is a bit above my knowledge.

We are going to have 3 web-servers… test, staging, production. We are going to use beanstalk (like github) which will store our repositories remotely and beanstalk will deploy to our servers via sftp (or ssh or whatever we decide). Inside our htdocs folder we have a drupal multi-site install, and we have a bunch of stuff outside of drupal (landing pages, etc…). We would like to have all of our htdocs (except images, file folders, etc…) inside of version control.

Should we use one repository with multiple branches? Or 3 separate repositories, each with one branch since they will be deploying to 3 separate servers?

Best Answer

As the code is going to be the same or versions of the same code, it would be healthier to have a single repository and several branches, one for each purpose. If you are in doubt on which branching scheme to use, there are many proposals out there (i.e. git flow).

As with git is so easy to port stuff from one branch to the other and back in the same repository, having separate repositories will give you a lot of headaches.

Additionally, you can have two branches on a repository that have completely different content, like for example the Bootstrap project: their code is on master branch and the github documentation pages are on another one.

And with Amazon Beanstalk you have to specify the branch you want to push to each environment, to this won't be a problem.

Git is so flexible you'll love it.

Related Topic