Blog

An Intro To Git

published 2021-08-07

Let's Talk About SemVer

Over time, code changes. Sometimes these changes can cause problems for other code that depends on it. This is where Semantic Version (AKA SemVer) comes in.

Sementic Versioning is a system for keeping track of code versions. It dictates that versions be written as Major.Minor.Patch.

Increases in major versions means that breaking changes have been introduced. Increases in minor versions means that new features have been implemented, but it's still backwards-compatible. Increases in patch versions means that it's still backwards-compatible but bugs have been fixed.

What is Git?

Git can kind of be thought about as Google Drive for code. It makes it so team members can all contribute to the same codebase, keeps said codebase stored somewhere other than your computer (which protects against crashes and whatnot), and also helps you keep track of your versioning using SemVer.

Git is usually accessed using GitHub, who make it free (unless you go for the paid features) and easy to set up git repositories (which are codebases for projects).

How Does It Work?

As previously mentioned, git uses repositories as containers for your projects' code. As you work on these projects, you commit your changes to it (essentially saying "this bit now works as intended for now") and then push (analogous to saving) your changes to the repository.

Git uses different branches to have different versions of your code. Any changes made to one branch don't immediately change the others, they are more or less isolated until you decide to merge them (where the changes made to one branch get added to the other).

The typical workflow using git is as follows: find a problem to solve, make a branch, fix the problem, merge the branch you made to the main one, repeat.

Teams will often have a little bit of a different workflow, since code usually has to be reviewed before it is merged to the main branch.

Other people can then download your code and use it in their projects. This is why it's important to use SemVer; it makes it so they don't accidentally update their version of your code and bring in breaking changes. It also makes it so you can refer to previous updates should anything go wrong with development (which makes finding bugs easier).

Why use it?

Git (especially when used with Github) makes life as a developer much easier. It keeps your code available wherever, keeps development organized, and makes working with teams much less chaotic.