Skip to content

Lesson 01 — Git Fundamentals

Imagine you’re working on an enterprise cloud automation project.

Today you write a Python script.

Tomorrow you accidentally delete half the code.

Next week another engineer modifies the same file.

A month later, your manager asks:

“Can you restore the version from last Friday?”

Without version control, recovering previous versions becomes extremely difficult.

This is exactly why Git exists.

Git allows developers to:

  • Track every change
  • Restore previous versions
  • Collaborate with teams
  • Merge code safely
  • Build software faster
  • Maintain complete project history

Today, Git is one of the most important skills for every IT professional—not just software developers.

Cloud Engineers, DevOps Engineers, Platform Engineers, Security Engineers, AI Engineers, and Site Reliability Engineers use Git every day.


After completing this lesson, you will be able to:

  • Understand Version Control Systems.
  • Learn why Git was created.
  • Understand Git architecture.
  • Install Git.
  • Configure Git.
  • Create repositories.
  • Track file changes.
  • Create commits.
  • View project history.
  • Understand Git workflows.
  • Apply Git in Cloud, DevOps, AI, and Cybersecurity.

A Version Control System (VCS) tracks changes made to files over time.

Instead of saving multiple copies like:

project-final
project-final-new
project-final-final
project-final-latest
project-final-v2
project-final-v2-final

Git stores every version automatically.

You can return to any previous version whenever needed.


Version Control helps teams:

  • Track changes
  • Restore previous versions
  • Collaborate safely
  • Prevent accidental data loss
  • Audit modifications
  • Improve productivity

Modern software development depends on version control.


Git is a Distributed Version Control System (DVCS) created by Linus Torvalds in 2005.

Git records every change made to a project and allows multiple developers to work together without overwriting each other’s work.

Git is:

  • Fast
  • Reliable
  • Open Source
  • Distributed
  • Widely adopted

Today it is the industry standard for version control.


Before Git, developers struggled with:

  • Slow version control systems
  • Merge conflicts
  • Limited collaboration
  • Central server dependency

Git solved these challenges by introducing a distributed model where every developer has a complete copy of the repository.


Centralized vs Distributed Version Control

Section titled “Centralized vs Distributed Version Control”
Developer
Central Server
Project Files

Examples:

  • SVN
  • CVS

Disadvantages:

  • Single point of failure
  • Internet dependency
  • Limited offline work

Developer A
Local Repository
Developer B
Local Repository
Remote Repository

Examples:

  • Git

Advantages:

  • Offline work
  • Faster operations
  • Complete history
  • Better collaboration

Git consists of three main areas:

Working Directory
Staging Area
Local Repository

Later, changes can be pushed to a remote repository such as GitHub.


The Working Directory contains the files you’re currently editing.

Example:

project/
|
|-- app.py
|-- README.md
|-- requirements.txt

Any modifications begin here.


The Staging Area acts as a preparation zone.

Only selected changes move into the next commit.

Example:

Terminal window
git add app.py

Git now knows this file should be included in the next commit.


A Repository (Repo) stores:

  • Files
  • Commit history
  • Branches
  • Tags
  • Configuration

Repositories are the heart of every Git project.


Download Git from:

https://git-scm.com

Install it using the default settings.

Verify installation:

Terminal window
git --version

Example output:

git version 2.49.0

Before using Git, configure your identity.

Terminal window
git config --global user.name "John Doe"
git config --global user.email "john@example.com"

Verify configuration:

Terminal window
git config --list

Navigate to your project folder.

Terminal window
mkdir my-project
cd my-project

Initialize Git:

Terminal window
git init

Output:

Initialized empty Git repository

Git creates a hidden folder:

.git

This folder stores all repository metadata.


Check the current repository status.

Terminal window
git status

Example:

On branch main
No commits yet

git status is one of the most frequently used Git commands.


Create a file:

README.md

Stage it:

Terminal window
git add README.md

Stage all files:

Terminal window
git add .

The files are now ready to be committed.


A commit records a snapshot of your project.

Terminal window
git commit -m "Initial project setup"

Each commit has:

  • Unique ID
  • Author
  • Timestamp
  • Commit message

Display previous commits.

Terminal window
git log

Example:

commit a4b8e...
Author
Date
Initial project setup

A project’s complete history is always available.


Modify File
git add
git commit
Repository Updated

This is the core Git workflow used by developers worldwide.


See what has changed.

Terminal window
git diff

Git highlights additions and deletions before committing.


Delete a tracked file.

Terminal window
git rm file.txt

Commit the change afterward.


Rename a file.

Terminal window
git mv old.txt new.txt

Git tracks the rename operation.


Create:

.gitignore

Example:

*.log
*.tmp
venv/
__pycache__/

Ignored files are not tracked by Git.


Tags identify important milestones.

Example:

Terminal window
git tag v1.0

Common uses:

  • Software releases
  • Production versions
  • Milestones

Commit 1
Commit 2
Commit 3
Commit 4

Git allows you to inspect or restore any previous version.


Cloud Engineers use Git to manage:

  • Terraform
  • CloudFormation
  • Kubernetes YAML
  • Infrastructure scripts
  • AWS Lambda code
  • Configuration files

Infrastructure becomes version controlled and reproducible.


DevOps Engineers use Git for:

  • Source code
  • Infrastructure as Code
  • CI/CD pipelines
  • Dockerfiles
  • Kubernetes manifests
  • Deployment automation

Git is the foundation of DevOps workflows.


Security teams manage:

  • Detection rules
  • SIEM configurations
  • Incident response playbooks
  • Threat hunting scripts
  • Compliance documentation
  • Security automation

Git provides change tracking and auditability.


AI Engineers store:

  • Training code
  • Machine learning models
  • Datasets (metadata)
  • Experiment configurations
  • Jupyter notebooks

Git supports reproducible AI workflows.


Command Purpose
git init Create repository
git status Check repository status
git add Stage files
git commit Save changes
git log View history
git diff Compare changes
git rm Remove file
git mv Rename file
git tag Create version tag
git config Configure Git

Avoid these mistakes:

  • Forgetting to commit changes.
  • Writing unclear commit messages.
  • Committing temporary files.
  • Ignoring .gitignore.
  • Editing files without checking status.
  • Making very large commits.

Small, meaningful commits make projects easier to maintain.


Professional development teams:

  • Commit frequently.
  • Write meaningful commit messages.
  • Use .gitignore.
  • Review changes before committing.
  • Keep commits focused on one task.
  • Maintain a clean repository history.

These practices improve collaboration and code quality.


A Cloud Engineer updates a Terraform configuration.

Workflow:

Modify terraform.tf
git status
git add .
git commit
Push to GitHub
CI/CD Pipeline Executes
Infrastructure Updated

Every change is recorded, reviewed, and can be restored if necessary.


After completing this lesson, you should understand:

  • Version Control
  • Git
  • Distributed repositories
  • Working Directory
  • Staging Area
  • Repository
  • Commits
  • Git Status
  • Git Log
  • Git Tags
  • Git Best Practices

Git is the foundation of modern software development and infrastructure management.

By tracking changes, maintaining version history, and enabling collaboration, Git helps individuals and teams build reliable, maintainable, and scalable projects.

Whether you’re working in Cloud Computing, DevOps, Artificial Intelligence, or Cybersecurity, Git is an essential tool that you’ll use throughout your career.


➡️ Lesson 02 — GitHub

In the next lesson, you’ll learn how to use GitHub, the world’s most popular Git hosting platform. You’ll create repositories, push local projects to GitHub, collaborate with teams, manage pull requests, and explore how GitHub powers enterprise software development and DevOps workflows.