Version Control, Git, and Remotes

Version Control

A version control system (VCS) tracks the history of changes as people and teams collaborate on projects together. As the project evolves, teams can run tests, fix bugs, and contribute new code with the confidence that any version can be recovered at any time. Developers can review project history to find out:

  • Which changes were made?
  • What was changed?
  • Who made the changes?
  • When were the changes made?
  • Why were changes needed?

Software teams that do not use any form of version control often run into problems. Developers who have never used version control may have added versions to your files, perhaps with suffixes like “final” or “latest” and then had to later deal with a new “final” version. Perhaps you’ve dealt with commented out code blocks because you want to disable certain functionality without deleting the code, fearing that there may be a use for it later. Version control is a way out of these problems.

Git

Git is a version control system (VCS). We recommend that Git is used along with a hosting repository (a remote), such as GitHub (or Gitea, GitLab, etc.) and that the GitHub Workflow is followed. However, Git can be used locally while working on a project. The steps outlined in Quick Start Git are for this purpose and should only be followed for a personal project that is local or on your personal network folder. For collaborative work, see Quick Start GitHub.

According to the latest Stack Overflow developer survey, more than 90 percent of developers use Git, making it the most-used VCS in the world (and most used tool in general). This has remained high but grown from 2017 which was at around 75% of developers. Git is commonly used for both open source and commercial software development, with significant benefits for individuals, teams and businesses:

  • Entire timeline of changes, decisions, and progression of any project in one place.
  • With a VCS like Git, collaboration can happen any time while maintaining source code integrity. Using branches, developers can safely propose changes to production code.
  • Businesses using Git can break down communication barriers between teams and keep them focused on doing their best work. Plus, Git makes it possible to align experts across a business to collaborate on major projects.

A repository is Git’s encompassing of the entire collection of files and folders associated with a project, along with each file’s revision history. The file history appears as snapshots in time called commits (versions), these commits can be organized into multiple lines of development called branches (separate areas of development on the same project). Using the command line or other ease-of-use interfaces, a Git repository also allows for: interaction with the history, cloning (copying), creating branches, committing (saving a version), merging (bringing two versions together), comparing changes across versions of code, and more. This is a lot of information but as you start using Git it’ll all embed and the terminology will be second nature.

Branches

Creating branches allows development and work to continue without affecting the main stream, it also allows many people to do work in parallel without overwriting each others work. Branching works by taking a copy of the main code and then later merging back when the code is ready. Before the marge takes place, reviews can take place to gain feedback and ensure the implemented changes will have the desired effect.

Remotes

Version control has great potential to facilitate collaborative working with colleagues and third parties. This can be utilised with the use of “remote” repositories - copies of a project hosted away from the workspace e.g. on GitHub or Gitea. There’s more about this later when we talk about GitHub, but for just now, this is a little introduction so you’re familiar with the term.

Systems like Git allow us to move work between any two repositories. In practice, though, it’s easiest to use one copy as a central hub, and to keep it on the web/private network rather than on someone’s laptop. This is where remotes come in. Most use hosting services like GitHub, BitBucket or GitLab to hold those master copies. In addition to using GitHub internally, we also have Gitea available as in internally hosted remote.

GitHub is a Git hosting repository that provides users with tools to ship better code through command line features, issues, pull requests, and code review. GitHub builds collaboration directly into the development process. Work is organised into repositories, where users can outline requirements or direction and set expectations for team members. Then, using a specific workflow, developers can simply create a branch to work on updates, commit changes to save them, open a pull request to propose and discuss changes, and merge pull requests once everyone is on the same page. See Workflows for more details.