| # | Section |
|---|---|
| 1 | Why Git? |
| 2 | Installing Git |
| 3 | Initial configuration |
| 4 | Verify the installation |
| 5 | Going further — aliases and default editor |
| 6 | Quiz — Installation and configuration |
| 7 | Practice — Configure your Git |
| 8 | Summary |
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:
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.
Installation depends on your operating system.
Download Git for Windows from git-scm.com. The installer also provides Git Bash, a convenient terminal.
# With Homebrew
brew install gitsudo apt update
sudo apt install gitsudo dnf install gitTip: 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.
sudo apt update
sudo apt install gitBefore the first commit, Git needs to know who you are. This information will appear in the history of every commit.
# 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"| Option | Scope | File concerned |
|---|---|---|
--global | All your repositories (your user) | ~/.gitconfig |
--local (default) | The current repository only | .git/config |
--system | All users on the machine | system config |
# Set the default branch to "main"
git config --global init.defaultBranch main
# Handle line endings (important on Windows)
git config --global core.autocrlf true
--globalconfiguration 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.
git config --global user.name "First Last"
git config --global user.email "you@example.com"# 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.emailIf
git --versionreturns “command not found”, Git is not installed, or its folder is not in thePATHvariable. 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.
git --version
# → git version 2.43.0 (or similar)Git sometimes opens an editor (to write a commit message, for example).
# Use VS Code as the Git editor
git config --global core.editor "code --wait"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.
| Alias | Equivalent to | Benefit |
|---|---|---|
git st | git status | Shorter |
git co | git checkout | Shorter |
git lg | git log --oneline --graph --all | Readable 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.
git config --global alias.st statusThen git st is equivalent to git status.
Question 1: Which command displays the installed Git version?
a) git version --check
b) git --version
c) git -v install
d) git status
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
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
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
Answer: b) — Unlike centralized VCS tools, everyone has a full copy and can work offline.
main as the default branch.# 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 --listExpected result of git config --list:
user.name=First Last
user.email=you@example.com
init.defaultbranch=main
core.autocrlf=trueIf your name and email appear, your Git is ready. You can move on to creating your first local repository (lesson 04).
git-scm.com (Windows), brew/apt/dnf (macOS/Linux).user.name and user.email with --global.git --version and git config --list.Lesson 06 — Local repository and commits: create your first repository and record your first changes.
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