Module 1 Lesson 4: Installing and configuring Git
·DevOps

Module 1 Lesson 4: Installing and configuring Git

Get Git up and running on your machine. We cover installation for all OSs and the essential configuration steps to identify yourself to Git.

Module 1 Lesson 4: Installing and configuring Git

Now that you understand how Git works, it’s time to install it. In this lesson, we cover the setup process and the essential configurations you need to perform before you commit your first line of code.


1. Installation

On Windows

The easiest way is to download the Git for Windows installer from git-scm.com.

  • Follow the setup wizard.
  • Tip: When asked about the default editor, choose the one you use most (like VS Code or Vim).
  • This installation includes Git Bash, a terminal that allows you to use Git commands just like you would on a Mac or Linux machine.

On macOS

If you have Homebrew installed, simply run:

brew install git

Alternatively, Mac users can simply type git in their terminal. If it's not installed, macOS will prompt you to install Xcode Command Line Tools, which includes Git.

On Linux (Ubuntu/Debian)

sudo apt update
sudo apt install git

Verification

Once installed, open your terminal (or Git Bash) and type:

git --version

If it returns something like git version 2.40.1, you are ready!


2. Global Configuration

Git needs to know who is making changes. This information is attached to every commit you ever make.

Run the following commands, replacing the values with your actual info:

# Set your name
git config --global user.name "Your Name"

# Set your email (use the same one as your GitHub account)
git config --global user.email "yourname@example.com"

Why use --global?

The --global flag tells Git to use these settings for every repository on your computer. If you want to use a different name for a specific work project, you can run the same commands inside that project folder without the --global flag.

Other Useful Configs:

# Set the default branch name to 'main' (highly recommended)
git config --global init.defaultBranch main

# List all your current settings
git config --list

3. The .gitconfig file

All these commands simply write to a text file on your computer.

  • Mac/Linux: Located at ~/.gitconfig
  • Windows: Located at C:\Users\YourName\.gitconfig

You can open this file in a text editor to see and edit your settings manually.

graph TD
    User["User Input"] --> CLI["git config command"]
    CLI --> File[".gitconfig file (Disk)"]
    File --> Commit["git commit process"]
    Commit --> History["Git History (Identity Embedded)"]

Module 1 Practice Exercises

It's time for your first hands-on challenge. Complete these three tasks to verify your setup:

  1. Verify Installation: Open your terminal and run git --version. Ensure the version is 2.x or higher.
  2. Identity Setup: Configure your user.name and user.email globally.
  3. Verify Configuration: Run git config --list and find your name and email in the output.

Checkpoint: If you can see your email in the config list, you have successfully initialized your local Git environment!


Summary

In this lesson, we established:

  • How to install Git on Windows, Mac, and Linux.
  • The importance of identifying yourself using user.name and user.email.
  • That configuration settings are stored in a persistent .gitconfig file.

Module Complete! You have the tools, the knowledge of the architecture, and the identity setup.

Next Module: We’ll move out of the configuration phase and start Module 2: Creating and Managing Repositories. You'll finally initialize your very first Git repository!

Subscribe to our newsletter

Get the latest posts delivered right to your inbox.

Subscribe on LinkedIn