WordPress Event Ticketing

Getting Started With Version Control

Version control. Maybe you've heard of it but aren't sure what it is? Or perhaps it's something you feel you should be using but aren't really sure how it works. In this article, we'll explore what version control is and how it can help you with your development or even writing!

 

What Is Version Control?

In it's most simplistic form version control is a single system that records changes to individual files or sets of files so that you can switch back to specific versions at a later date. Version control is most often used with software and development though you could use version control to track changes in any project you work on including txt files or anything you want.

Not sure what is Tickera? Go here to find out!

There are multiple different types of version control platforms. For the purpose of this article, we'll be covering the main ones used in WordPress development. One called Subversion or SVN for short and one called Git. If you'd like to see a complete list of version control software available you can see one here.

 

Why Use Version Control?

Version Control is extremely useful for tracking changes and ensuring nothing breaks. Rather than constantly changing your code and not having a history of what was changed with version control you can commit your changes. Make more changes, commit those changes and if something breaks you can quickly and easily revert to your previous working versions. If you weren't using Version Control, you might not have known what was changed or modified to break your code if you'd made many changes.

Version Control is incredibly useful for teams of developers.

Utilizing version control, multiple team members can work on the same codebase without effecting each other's work and constantly overwrite it. When you make a commit if a conflict is found when trying to merge you can pick which version to use (yours or team members) or modify and pull down their changes into your local copy and then apply the changes you want and push it back up. Version Control saves the headache of everyone constantly messing up everyone else's code.

 

Branches

Branches are the best way to use version control. How it works is you'd have a master branch which is the master version of the project you're working on. Then you'd have branches for either other team members or specific features. This means that the master branch is always kept "clean" and is known to be the official release ready version rather than something that is in progress and possibly broken. It also is useful if you'd prefer a more senior member of your development team to review commits from junior developers before merging with the master branch. Ensuring any issues are found and resolved before getting merged into your master branch.

 

Pull Requests

Pull Requests let you tell the repository owners about what changes you've made. The repository owner can then review the changes made, leave comments and discuss any modifications needed. They can then merge the pull request into the branch. If there are conflicts to resolve first they can also be fixed before merging into the branch.

 

Stashing

Stashing your changes allows you to save your tracked modified files and staged changes as an unfinished modification that can be reapplied at any time.

 

Forking

You can fork a repository. Forking is usually done when you're working on an open-source project and want to contribute. Once you've forked a project and made modifications, you can then submit a pull request to the original repository with your modifications. Or you could fork an open-source project that is longer being maintained to give it a new lease of life. You should always check the license attached to any project before forking it and re-distributing the project.

 

Subversion (SVN)

Subversion or SVN for short is an open-source Version Control system. SVN is what is used over on WordPress.org and is the platform you must use when submitting your plugins or themes for inclusion on WordPress.org. While it's often seen as a more complex system than Git it used to be the default for most developers until Git came onto the scene. There are multiple different apps you can use as a GUI if you'd rather not use the command line for commuting and using SVN. These include:

  • Versions App  - Versions is a SVN GUI for Mac/OSX. Simple and easy to use it's the perfect application to use if you'd rather not use the command line. It isn't compatible with Windows.
  • Tortoise SVN  - Tortoise is an SVN GUI for Windows that is free to use and one of the best GUI SVN clients for Windows users.

While subversion is still widely used if you aren't going to be submitting to WordPress.org or work with a team that already uses SVN there's no real reason to use it over the much more popular and easier to use Git.

 

Git

Git, unlike SVN, is a distributed open source version control system. The main difference between the distributed version control systems and SVN which is a client-server model is that distributed version control systems developers work with their own local repositories rather than one central repository.

One misconception is that GitHub is Git. Which is incorrect.

GitHub is a centralized collection of Git repositories that allows developers and teams to host their own Git repositories on GitHub and collaborate with other developers on their projects as well.

Just as with SVN there are popular Git GUIs that make it easy and simple to use Git rather than using the command line. Including:

  • GitHub Official App - The GitHub App is the official app for use with GitHub repositories. Popular amongst developers and extremely easy to use.
  • Tower - Tower is a full featured Git GUI that works with both Windows and Mac. Powerful and easy to use.
  • SourceTree - SourceTree is a Git GUI created by Atlassian, the same people behind Jira and BitBucket. Free to use and available for both Windows and Mac

 

Online Git Repositories

There are two main players in online repository hosting, one is GitHub. GitHub is an online repository hosting service for individuals and teams.

By default your repositories are public. Though for a small monthly payment you can make repositories private.

GitHub is easy to use and perfect for collaboration amongst developers and individuals on larger open-source projects. Developers can star each other's project as well as fork them quickly and easily.

 

BitBucket is very similar to GitHub with the main difference being BitBucket is free for individuals for use with private repositories which means its perfect for use if you wish to keep that project you've been working on a secret.

There is no right or wrong choice when it comes to BitBucket or SourceTree rather it's a matter of personal preference.

 

Verdict

Version Control is an important aspect of any modern development workflow. Allowing you to work easily in teams and contribute to other projects. Have you ever had any issues with version control? Maybe you've tried using it before, and it never worked out? Let us know in the comments below.

Leave Us A Message!