Git: Installation and Configuration

5 min

Table of contents


1 — Why Git?

Git is a distributed version-control system (VCS). It records the history of your code: every change, who made it, when, and why.

Without Git, you cobble together folders named projet_final, projet_final_v2, projet_final_vraiment_final… Git replaces that chaos with a clean, navigable history.

What Git enables:

  • Go back to any earlier version.
  • Work with several people without overwriting each other (branches, merges).
  • Trace every change (who, what, when, why).
  • Serve as the foundation of all DevOps: CI/CD, deployments, collaboration.

Git is distributed: each person has a complete copy of the repository, history included. You do not need to be connected to a server to work.

↑ Back to top


2 — Installing Git

Installation depends on your operating system.

Windows

Download Git for Windows from git-scm.com. The installer also provides Git Bash, a convenient terminal.

macOS

bash
# With Homebrew
brew install git

Linux (Debian / Ubuntu)

bash
sudo apt update
sudo apt install git

Linux (Red Hat / Fedora)

bash
sudo dnf install git

Tip: accept the default options of the Windows installer unless you know what you are changing. They fit the vast majority of cases.

🔧 Mini-exercise — Write the command to install Git on a Debian/Ubuntu Linux distribution.

✅ See a solution
bash
sudo apt update
sudo apt install git

↑ Back to top


3 — Initial configuration

Before the first commit, Git needs to know who you are. This information will appear in the history of every commit.

bash
# Your name (visible in the commit history)
git config --global user.name "First Last"

# Your email (ideally the same as on GitHub)
git config --global user.email "you@example.com"
OptionScopeFile concerned
--globalAll your repositories (your user)~/.gitconfig
--local (default)The current repository only.git/config
--systemAll users on the machinesystem config
bash
# Set the default branch to "main"
git config --global init.defaultBranch main

# Handle line endings (important on Windows)
git config --global core.autocrlf true

--global configuration is done once per machine. After that, all your repositories inherit it automatically.

🔧 Mini-exercise — Write the two commands that configure your Git name and email globally.

✅ See a solution
bash
git config --global user.name "First Last"
git config --global user.email "you@example.com"

↑ Back to top


4 — Verify the installation
bash
# Check the installed version
git --version
# → git version 2.43.0  (or similar)

# Check your configuration
git config --list

# Check a specific setting
git config user.name
git config user.email

If git --version returns “command not found”, Git is not installed, or its folder is not in the PATH variable. On Windows, opening a new terminal after installation often solves the problem.

🔧 Mini-exercise — Run the command that displays the Git version installed on your machine.

✅ See a solution
bash
git --version
# → git version 2.43.0 (or similar)

↑ Back to top


5 — Going further — aliases and default editor

Set the default editor

Git sometimes opens an editor (to write a commit message, for example).

bash
# Use VS Code as the Git editor
git config --global core.editor "code --wait"

Create aliases (shortcuts)

bash
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.lg "log --oneline --graph --all"

Then git st is equivalent to git status, git lg displays a readable history graph, and so on.

AliasEquivalent toBenefit
git stgit statusShorter
git cogit checkoutShorter
git lggit log --oneline --graph --allReadable history

Aliases are a small comfort that saves time every day. Optional, but appreciated.

🔧 Mini-exercise — Create a global alias st that runs git status, then say how to use it.

✅ See a solution
bash
git config --global alias.st status

Then git st is equivalent to git status.

↑ Back to top


6 — Quiz — Installation and configuration

Question 1: Which command displays the installed Git version?

a) git version --check

b) git --version

c) git -v install

d) git status

See the solution

Answer: b)git --version displays the version (e.g. git version 2.43.0) and confirms that Git is installed.


Question 2: What does git config --global user.email "..." do?

a) Log in to GitHub

b) Record the email associated with your commits, for all your repositories

c) Send an automatic email

d) Delete a repository

See the solution

Answer: b) — With --global, this email is attached to your commits in every repository on the machine.


Question 3: What does the --global option do?

a) Applies the setting to all repositories of your user

b) Applies the setting only to the current repository

c) Shares the setting with the whole world

d) Deletes the configuration

See the solution

Answer: a)--global writes to ~/.gitconfig and applies to all your repositories. Without the option, the setting is local to the current repository.


Question 4: What does “Git is distributed” mean?

a) Git is paid

b) Each user has a complete copy of the repository, history included

c) Git only works online

d) Git erases history on every commit

See the solution

Answer: b) — Unlike centralized VCS tools, everyone has a full copy and can work offline.

↑ Back to top


7 — Practice — Configure your Git

Instructions

  1. Install Git if it is not already installed.
  2. Configure your name and email globally.
  3. Set main as the default branch.
  4. Verify your entire configuration.

Correction — Expected command sequence

bash
# 1. Verify the installation
git --version

# 2. Configure identity
git config --global user.name "First Last"
git config --global user.email "you@example.com"

# 3. Default branch
git config --global init.defaultBranch main

# 4. Verify
git config --list

Expected result of git config --list:

user.name=First Last
user.email=you@example.com
init.defaultbranch=main
core.autocrlf=true

If your name and email appear, your Git is ready. You can move on to creating your first local repository (lesson 04).

↑ Back to top


8 — Summary

Key takeaways

  1. Git is a distributed version-control system: everyone has a complete copy.
  2. Installation: git-scm.com (Windows), brew/apt/dnf (macOS/Linux).
  3. Minimum configuration: user.name and user.email with --global.
  4. Verification: git --version and git config --list.
  5. Optional comfort: default editor and aliases.

What's next

Lesson 06 — Local repository and commits: create your first repository and record your first changes.

↑ Back to top


All rights reserved. Any reproduction, distribution, use or adaptation of this course, in whole or in part, is strictly prohibited without the prior written authorization of Dr. Haythem REHOUMA.

Course created by Dr. Haythem REHOUMA — Development and Deployment of Data Solutions