Git basics & source code versioning
Last modified on Mon 17 Jul 2023

You can see a lot by just looking.

Git and GitHub

What is Git?

Git is a Version Control System (VCS). On a very basic level, there are two awesome things a VCS allows you to do:

There are multiple Version Control Systems, but Git is by far and large the most popular — both for individual and company use.

You should already have Git installed on your macOS. To check, just run in Terminal:

git --version

What is GitHub?

On the other hand, GitHub is a web-based Git repository (referred to as a remote repository).

There are also other similar services like BitBucket and Gitlab, but in Infinum we are mostly using GitHub.

Thou shalt use 2FA everywhere where we use Git!

Source code versioning

When using a version control system:

SSH keys

Before you start with Git, we encourage you to connect to GitHub or Bitbucket with SSH keys. Using the SSH key, you’ll manage (clone, push, pull..) private repositories without entering your email/username password each time you need to operate on the remote repository.

GitHub has excellent docs on SSH, how it is used, how to generate one and connect it with your account. First of all, you need to generate a public/private SSH key pair, then add the public part to GitHub and Bitbucket accounts. To do so on GitHub, follow these steps, and for Bitbucket these. You can reuse the same SSH key for both GitHub and Bitbucket. To use the SSH key for access, clone the repository using the SSH clone URL.

.gitconfig

You should set username and email properties in your .gitconfig file, which are then associated with each commit you create. You can set those by executing the following commands:

git config --global user.name "Full Name"
git config --global user.email "your.mail@infinum.com"

.gitconfig is stored inside of your home directory ~/.gitconfig where you can take a look at how it looks or edit it manually. But those commands above will be sufficient for adding your name and email.