git-version-control

Having version control for your Drupal website is an incredibly useful tool. It not only benefits the programming workflow if you are are involved with custom module development, but also is beneficial if your primary concern is just support for Drupal core and module updates.

Version control helps make it easier to deploy new code, keep track of changes in your code, and if there are problems, to roll back your code to the previous version from before the error came about. If you are using applying updates or changes directly to your code (definitely a bad idea for a live website) not having version control in place can make rolling back changes very laborious and could potentially introduce even more errors.

"Git" With the Program!

Git is a popular version control system that is used extensively throughout the open source web development community.

You can download Git easily from this webpage: http://git-scm.com/downloads with additional information about how to install Git provided here: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git.

Now, it's one thing to just install Git, but it's another thing to make use of version control like Git in a way that is beneficial to your workflow, and helps keep your Drupal websites in good working order during updates. Here are some guidelines to help you along the way.

1. Set up a central or remote repository to work off of. A repository is a term for a contained set of files and commit objects for a Git controlled project. It is like a history of the changes made to the project over time. By having a remote repository to act as your official source (perhaps at a provider like BitBucket.org) it can function as a sort of backup for your code. Additionally, it can be helpful as the transition space to provide for moving your project and it's code between different server environments, like with a Dev->Staging->Production workflow.

2. Use forks and branches so that you aren't always immediately pushing changes to your primary repository. Sometimes you may want to test changes and it could take a little way to do that, but in the meantime, an important emergency patch needs to be applied. If you are constantly pushing changes to your primary repository, the one you use to update your production website, then you may get in a situation where you have to pull in changes that you aren't ready to deploy yet.

You can learn more about Git "branches" and a "forking workflow" with these helpful tutorials (branches) and (forking) and a more advanced fork/pull-request workflow for teams .

One of the most important things to remember is that while version control can help you out in a tough situation by making it easier to rollback or update code, it won't actually make sure your code is well formulated or your patches don't create other problems. Always be sure to test your updates thoroughly.

 

Need more help working with version control?

We might be able to help you! Contact Us