Skip to content

Lesson 01 — Git Fundamentals

Foundation workshop: View the full Module 06 learning guide for prerequisite skills, a professional scenario, expected observations and exercises.

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.

Architecture and workplace practice — Git history and controlled release

Section titled “Architecture and workplace practice — Git history and controlled release”

These are conceptual diagrams for the free Foundation lesson. They help you reason about an enterprise system; they are not records of a production deployment.

flowchart LR
    WORK["Working directory changes"] --> REVIEW["Inspect git status and diff"]
    REVIEW --> STAGE["Stage intended files"]
    STAGE --> CHECK["Review staged diff"]
    CHECK --> COMMIT["Commit snapshot locally"]
    COMMIT --> HISTORY["Traceable repository history"]

How to read the diagram: Git separates working files, the staging index and recorded commits. A commit does not automatically upload code or trigger a deployment.

flowchart TD
    BRANCH["Feature branch and scoped change"] --> PR["Open pull request"]
    PR --> CI["Build, tests and security checks"]
    CI --> READY{"Tests and review approved?"}
    READY -->|"No"| FIX["Repair and retest"]
    FIX --> CI
    READY -->|"Yes"| MERGE["Merge approved change"]
    MERGE --> DEPLOY["Controlled deployment"]
    DEPLOY --> MONITOR["Monitor, verify and roll back if needed"]

How to read the diagram: A passing CI run is one release gate, not a guarantee of security. Teams also need approvals, rollback plans and operational validation.

A developer updates a troubleshooting runbook and wants to publish it safely. A reviewer checks exact changes, test results and that no tokens or sensitive screenshots entered the commit.

Create a local Git practice repository, commit a harmless README, inspect the staged diff, then write a simulated pull-request description with tests and rollback.

Expected evidence: A local commit history, PR checklist and a release lifecycle diagram. No GitHub account or production deployment required.

  • D

    Show suggested reasoningo
  • N

    Show suggested reasoningo
  • D

    Show suggested reasoningo
  • N

    Show suggested reasoningo

Continue learning: Open the Module 06 deep-dive or see GHC Labs and its optional advanced practice. Foundation lessons remain free; hosted labs have separate access terms.


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.


Extended Foundation Workshop — A reviewable Git change

Section titled “Extended Foundation Workshop — A reviewable Git change”

Git is useful beyond software development. Security teams use it to version-control detection rules, operational runbooks, investigation templates and configuration changes. A reviewer should always be able to answer: what changed, why, how was it tested, and how will we undo it?

A team wants to improve a troubleshooting procedure. Rather than editing a shared document without history, one engineer creates a focused change, checks what is staged and records a commit explaining the reason.

Run in Git Bash, Linux or macOS shell on your own computer:

Terminal window
mkdir foundation-operations-notes
cd foundation-operations-notes
git init -b main
git config user.name "Foundation Learner"
git config user.email "learner@example.invalid"
printf '# Operations Notes\n' > README.md
git status
git add README.md
git diff --cached
git commit -m "docs: create operations learning notebook"
git log -1 --oneline

The email shown is an intentionally invalid demonstration address. You do not need an online GitHub account for this exercise.

Expected observation: a local repository with one tracked README file and a commit. The commit hash and timestamp vary by machine.

Edit files
|
git status -> inspect what's changed
|
git add -> stage intended changes
|
git diff --cached -> review staged content
|
git commit -> record a new snapshot
|
Team review / CI / controlled deployment (separate steps)

A local commit does not automatically publish to GitHub or deploy a production application. That distinction is important when learning DevOps.

Before git add ., inspect what the command would stage. Avoid committing .env files, secrets, tokens, personal data, customer information or sensitive internal diagrams. A .gitignore helps but does not erase previously committed secrets.

  1. What does git diff --cached show?

    Suggested answerThe changes already staged for the next commit, rather than all unstaged working-tree modifications.
  2. Does successful CI prove a production rollout is safe?

    Suggested answerNo. Tests only validate their specified coverage. Release approvals, rollback planning, environment differences and monitoring still matter.

Add a second commit with a network troubleshooting checklist. In a README, write a sample pull request description containing purpose, evidence, risks, tests and rollback. Then visit the Module 06 workshop, Academy Projects and GHC Labs overview.


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.