Lesson 01 — Git Fundamentals
Foundation workshop: View the full Module 06 learning guide for prerequisite skills, a professional scenario, expected observations and exercises.
Lesson Overview
Section titled “Lesson Overview”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.
Learning Objectives
Section titled “Learning Objectives”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.
The Git working-tree to commit lifecycle
Section titled “The Git working-tree to commit lifecycle”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.
Pull request to safe deployment
Section titled “Pull request to safe 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.
Workplace scenario
Section titled “Workplace scenario”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.
Independent exercise
Section titled “Independent exercise”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.
Check your understanding
Section titled “Check your understanding”-
D
Show suggested reasoning
o -
N
Show suggested reasoning
o -
D
Show suggested reasoning
o -
N
Show suggested reasoning
o
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.
What is Version Control?
Section titled “What is Version Control?”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-finalGit stores every version automatically.
You can return to any previous version whenever needed.
Why Version Control Matters
Section titled “Why Version Control Matters”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.
What is Git?
Section titled “What is Git?”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.
Why Was Git Created?
Section titled “Why Was Git Created?”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”Centralized Version Control
Section titled “Centralized Version Control”Developer
↓
Central Server
↓
Project FilesExamples:
- SVN
- CVS
Disadvantages:
- Single point of failure
- Internet dependency
- Limited offline work
Distributed Version Control
Section titled “Distributed Version Control”Developer A
↓
Local Repository
↔
Developer B
↓
Local Repository
↓
Remote RepositoryExamples:
- Git
Advantages:
- Offline work
- Faster operations
- Complete history
- Better collaboration
Git Architecture
Section titled “Git Architecture”Git consists of three main areas:
Working Directory
↓
Staging Area
↓
Local RepositoryLater, changes can be pushed to a remote repository such as GitHub.
Working Directory
Section titled “Working Directory”The Working Directory contains the files you’re currently editing.
Example:
project/
|
|-- app.py
|-- README.md
|-- requirements.txtAny modifications begin here.
Staging Area
Section titled “Staging Area”The Staging Area acts as a preparation zone.
Only selected changes move into the next commit.
Example:
git add app.pyGit now knows this file should be included in the next commit.
Repository
Section titled “Repository”A Repository (Repo) stores:
- Files
- Commit history
- Branches
- Tags
- Configuration
Repositories are the heart of every Git project.
Installing Git
Section titled “Installing Git”Download Git from:
https://git-scm.comInstall it using the default settings.
Verify installation:
git --versionExample output:
git version 2.49.0Configuring Git
Section titled “Configuring Git”Before using Git, configure your identity.
git config --global user.name "John Doe"
git config --global user.email "john@example.com"Verify configuration:
git config --listCreating a Repository
Section titled “Creating a Repository”Navigate to your project folder.
mkdir my-project
cd my-projectInitialize Git:
git initOutput:
Initialized empty Git repositoryGit creates a hidden folder:
.gitThis folder stores all repository metadata.
Git Status
Section titled “Git Status”Check the current repository status.
git statusExample:
On branch main
No commits yetgit status is one of the most frequently used Git commands.
Adding Files
Section titled “Adding Files”Create a file:
README.mdStage it:
git add README.mdStage all files:
git add .The files are now ready to be committed.
Creating a Commit
Section titled “Creating a Commit”A commit records a snapshot of your project.
git commit -m "Initial project setup"Each commit has:
- Unique ID
- Author
- Timestamp
- Commit message
Viewing Commit History
Section titled “Viewing Commit History”Display previous commits.
git logExample:
commit a4b8e...
Author
Date
Initial project setupA project’s complete history is always available.
Git Commit Workflow
Section titled “Git Commit Workflow”Modify File
↓
git add
↓
git commit
↓
Repository UpdatedThis is the core Git workflow used by developers worldwide.
Viewing Differences
Section titled “Viewing Differences”See what has changed.
git diffGit highlights additions and deletions before committing.
Removing Files
Section titled “Removing Files”Delete a tracked file.
git rm file.txtCommit the change afterward.
Renaming Files
Section titled “Renaming Files”Rename a file.
git mv old.txt new.txtGit tracks the rename operation.
Ignoring Files
Section titled “Ignoring Files”Create:
.gitignoreExample:
*.log
*.tmp
venv/
__pycache__/Ignored files are not tracked by Git.
Git Tags
Section titled “Git Tags”Tags identify important milestones.
Example:
git tag v1.0Common uses:
- Software releases
- Production versions
- Milestones
Git History Example
Section titled “Git History Example”Commit 1
↓
Commit 2
↓
Commit 3
↓
Commit 4Git allows you to inspect or restore any previous version.
Git in Cloud Computing
Section titled “Git in Cloud Computing”Cloud Engineers use Git to manage:
- Terraform
- CloudFormation
- Kubernetes YAML
- Infrastructure scripts
- AWS Lambda code
- Configuration files
Infrastructure becomes version controlled and reproducible.
Git in DevOps
Section titled “Git in DevOps”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.
Git in Cybersecurity
Section titled “Git in Cybersecurity”Security teams manage:
- Detection rules
- SIEM configurations
- Incident response playbooks
- Threat hunting scripts
- Compliance documentation
- Security automation
Git provides change tracking and auditability.
Git in AI
Section titled “Git in AI”AI Engineers store:
- Training code
- Machine learning models
- Datasets (metadata)
- Experiment configurations
- Jupyter notebooks
Git supports reproducible AI workflows.
Common Git Commands
Section titled “Common Git Commands”| 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 |
Common Beginner Mistakes
Section titled “Common Beginner Mistakes”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.
Enterprise Best Practices
Section titled “Enterprise Best Practices”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.
Real-World Example
Section titled “Real-World Example”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 UpdatedEvery 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?
Workplace scenario
Section titled “Workplace scenario”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.
Hands-on Git practice (local only)
Section titled “Hands-on Git practice (local only)”Run in Git Bash, Linux or macOS shell on your own computer:
mkdir foundation-operations-notescd foundation-operations-notesgit init -b maingit config user.name "Foundation Learner"git config user.email "learner@example.invalid"printf '# Operations Notes\n' > README.mdgit statusgit add README.mdgit diff --cachedgit commit -m "docs: create operations learning notebook"git log -1 --onelineThe 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.
Explain the workflow
Section titled “Explain the workflow”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.
Safety and professionalism
Section titled “Safety and professionalism”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.
Knowledge check
Section titled “Knowledge check”-
What does
git diff --cachedshow?Suggested answer
The changes already staged for the next commit, rather than all unstaged working-tree modifications. -
Does successful CI prove a production rollout is safe?
Suggested answer
No. Tests only validate their specified coverage. Release approvals, rollback planning, environment differences and monitoring still matter.
Portfolio deliverable
Section titled “Portfolio deliverable”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.
Key Takeaways
Section titled “Key Takeaways”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
Summary
Section titled “Summary”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.
Next Lesson
Section titled “Next Lesson”➡️ 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.