Command Shift

Git

The next tool we'll install is git.

Git is an open source version control system that will track your projects by creating a timeline of changes to your code. You can then see how your code has developed over time, and even revert changes if something goes wrong. This can be extremely helpful when working on large commercial projects with lots of contributors! It's designed to handle everything from small to very large projects with speed and efficiency. Any time you write some code that breaks your application, git will be there to save you with previous versions!

Git has other extremely useful features, but don't worry about these right now. You'll learn more about it later in this section of the course.

Installation

For macOS users:

  1. In your terminal, run: brew install git.

For Ubuntu users:

  1. In your terminal, run: sudo apt-get install git.

For both macOS & Ubuntu users:

Once the installation process is completed, you'll have to configure git so that your name and email address are associated with your commits (you'll learn about commits soon).

Using your own name and email, run the following commands:

  1. Run: git config --global user.name "John Doe"
  2. Run: git config --global user.email "johndoe@example.com"

Now we have done this, we can make one more change to the git configuration. The following command will ensure that your default branch when initialising a git repo is always named 'main' instead of 'master' (you'll learn about branches soon too!).

  • Run: git config --global init.defaultBranch main.

To read more about why Github encourages users to use the term 'main' instead of 'master', take a look at this article.

On this page