teluzia.Cloud Engineer · Day 5
CHAPTER 01 · LINUX FUNDAMENTALS AND GIT

Git repositories, commits and history

4–5 hours including independent practice3 topics
LET’S MAKE THIS SIMPLE

What you’re learning today

Create a local repository that tells a trustworthy story of a small change. You will inspect the working tree, stage one file, commit it and compare history with an uncommitted edit. No remote account is required. A repository stores Git objects and references under .git, while the working tree contains the files you edit. git init creates repository metadata; it does not upload anything. git status reports changes relative to the index and current commit. The index is the proposed content of the next commit. git add copies current file content into that proposal; later edits remain unstaged until added again. git commit records the staged snapshot together with identity, timestamp and message.

Think of it this way

Git is a project photo album: staging chooses the frame and committing records the labeled photograph.

TOPIC 01 / 03Step by step

Repository and working tree

A repository stores Git objects and references under .git, while the working tree contains the files you edit. git init creates repository metadata; it does not upload anything. git status reports changes relative to the index and current commit. Run git init -b main inside a new practice directory, then git status; an untracked note is outside recorded history. Separating project files from Git metadata explains why copying a visible file is different from cloning a repository with its history. Deleting .git removes local history metadata; never experiment on an existing project repository when a separate empty practice directory is sufficient today.

WORKED EXAMPLE
Run git init -b main inside a new practice directory, then git status; an untracked note is outside recorded history.
Why this matters

Separating project files from Git metadata explains why copying a visible file is different from cloning a repository with its history.

A common trap

Deleting .git removes local history metadata; never experiment on an existing project repository when a separate empty practice directory is sufficient today.

Read all topics in this lesson

A complete reference to revisit alongside the guided steps above.

Repository and working tree

A repository stores Git objects and references under .git, while the working tree contains the files you edit. git init creates repository metadata; it does not upload anything. git status reports changes relative to the index and current commit. Run git init -b main inside a new practice directory, then git status; an untracked note is outside recorded history. Separating project files from Git metadata explains why copying a visible file is different from cloning a repository with its history. Deleting .git removes local history metadata; never experiment on an existing project repository when a separate empty practice directory is sufficient today.

WORKED EXAMPLE
Run git init -b main inside a new practice directory, then git status; an untracked note is outside recorded history.

Why this matters

Separating project files from Git metadata explains why copying a visible file is different from cloning a repository with its history.

A common trap

Deleting .git removes local history metadata; never experiment on an existing project repository when a separate empty practice directory is sufficient today.

Staging and committing

The index is the proposed content of the next commit. git add copies current file content into that proposal; later edits remain unstaged until added again. git commit records the staged snapshot together with identity, timestamp and message. After git add notes.txt, edit notes.txt again; git diff and git diff --staged show different sets of changes to review. A deliberate staging step lets you record related changes together and review exactly what will enter history before publishing a repository externally. Assuming git add tracks every future edit can omit later changes; inspect both unstaged and staged diffs immediately before each commit you create.

WORKED EXAMPLE
After git add notes.txt, edit notes.txt again; git diff and git diff --staged show different sets of changes to review.

Why this matters

A deliberate staging step lets you record related changes together and review exactly what will enter history before publishing a repository externally.

A common trap

Assuming git add tracks every future edit can omit later changes; inspect both unstaged and staged diffs immediately before each commit you create.

History and differences

git log lists commits and their relationships; git show inspects a commit’s metadata and patch. git diff compares selected states rather than simply listing files. A meaningful message explains the purpose of a coherent snapshot so future readers can follow decisions. git log --oneline shows short identifiers; git show HEAD explains the newest commit, while git diff reports the current unstaged edit. History and comparisons provide evidence for debugging regressions and allow reviewers to understand how a project changed without relying on personal memory alone. Treating a commit as a backup of all directory contents ignores untracked and ignored files; verify status and staged content before trusting coverage.

WORKED EXAMPLE
git log --oneline shows short identifiers; git show HEAD explains the newest commit, while git diff reports the current unstaged edit.

Why this matters

History and comparisons provide evidence for debugging regressions and allow reviewers to understand how a project changed without relying on personal memory alone.

A common trap

Treating a commit as a backup of all directory contents ignores untracked and ignored files; verify status and staged content before trusting coverage.

KEEP THESE WITH YOU

Today’s takeaways

Inspect both staging and working-tree changes.

Commit cohesive changes with useful messages.

Local history exists before any remote is configured.

CLOSE THE LOOP

Ready to complete this day?

Verify the practical steps and pass the knowledge check (at least two thirds correct).

Lab steps verifiedKnowledge check passed