Version Control - Git a Handle on Your Code
1-23-2020What is Version Control?
Image Credit: Git
Version control, also known as revision control or source control greatly streamlines development lifecycles. Developers working in teams are constantly writing and making changes to the same source code which can cause issues if push processes are not followed consistently - this is where source control comes into play. Version control helps programmers work collaboratively and seamlessly on the same source code without overriding each other’s code updates - saving time and money.
Purpose and Benefits of Version Control
Developing software without version control is risky. Version control preserves the source code’s integrity. The use of version control can save countless hours by avoiding the need for programmers to manually file check and merge files together prior to deployment. Manually merging and pushing file changes are prone to human error and often times file conflicts arise which takes time to sort out – sometimes a lot of time, as it can introduce new bugs.
Development teams should be able to work concurrently on the same source code without a problem when using source control. Version control is a safety measure that still allows individual programmers to work within their preferred method, within their own development branch, and doesn’t require the entire development team to follow one standard process. Workflow flexiblity is great, but it is VERY important that all developers are in alignment on the processes for merging branches together.
What is the Best Version Control for my Team?
There are numerous different kinds of version control software available to development teams but Git is our favorite for a number of reasons. Git is trusted and is used by Google, Facebook, Microsoft, and Netflix’s development teams. Git is quick. Almost all operations occur locally and don’t require communication with a server. Git is free, open source, and it supports multiple workflows.
Git’s most common workflow options are:
- Basic – This workflow is popular if you are getting familiar with Git. This workflow includes one central code repository that each developer clones; they then work locally making code updates, commit changes, and the push their updates to the single repo for other developers to pull and use their work.
- Feature Branch – This workflow is reliant on branches. Branches are independent development paths; it is best to create a new branch for each update or introduction to new functionality. This allows developers to work within their new feature branch, test it, and then merge that branch to the master branch to go live.
- Gitflow – This workflow focuses on two long-running branches, one for development and one for the master. The development branch is where all feature branches are merged and all testing occurs before pushing updates to the master branch. This workflow method is well-suited for large projects.
These are only a couple examples of Git workflows. The beauty is that you can use established workflow methods, customize established methods to fit your team’s needs, or use your own workflow.
Git’s main pain point is it comes with a bit of a learning curve; Git’s robust features and multiple workflows can take some getting used to. Once development teams become familiar with Git, its tools can greatly increase development time and allows for faster release cycles. We recommend downloading Git visualizer like, Sublime Merge to help learn all nuances within Git.
Version Control Tips and Best Practices
There are several best practices for version control that should be applied by development teams:
- Use branches!
- Agree as a team on source control workflow to establish a process for merging branches.
- Review code updates in the staging area prior to making a commit.
- Log commit notes with enough detail to explain what the update you made does and why you made that update.
- Commit often to capture each update being made; this helps for bug tracking and is helpful if there is a need to revert code updates.
- Git IDs are helpful for rolling back updates from production if needed, make note of the ID before you push to production.
- Push branches are helpful when making several feature updates at once; this keeps the production branch clean.
- Learn all of Git’s commands – here is a cheat sheet.
Check out this nerdy, interactive game to learn Git branching and commands.