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

Branches, merges and GitHub workflow

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

What you’re learning today

Practice collaboration using a local bare repository as a safe remote. A branch isolates work, a merge combines histories, and a pull request adds review around a proposed change. You will also rehearse the GitHub sequence without publishing or sending messages. A branch is a movable reference to a commit. Creating a branch does not duplicate every file; switching updates the working tree to match that branch. git switch -c creates and selects a branch. Commit or safely preserve edits before changing contexts. A merge combines changes from two histories. When both sides modify the same area incompatibly, Git pauses for a human decision. Conflict markers show candidate text; they are not final content. After resolving, stage the file and complete the merge or abort it.

Think of it this way

Branches are alternate manuscript drafts; merging reconciles them; a pull request asks reviewers to inspect the reconciliation.

TOPIC 01 / 03Step by step

Branches and switching

A branch is a movable reference to a commit. Creating a branch does not duplicate every file; switching updates the working tree to match that branch. git switch -c creates and selects a branch. Commit or safely preserve edits before changing contexts. git switch -c feature-note creates a named work stream, and git branch identifies it with an asterisk in the listing. Short-lived branches separate unfinished work from the main line and provide clear boundaries for review, testing and eventual integration into shared history. Leaving unrelated uncommitted edits while switching branches can carry work into the wrong context; inspect status and commit coherent changes before switching.

WORKED EXAMPLE
git switch -c feature-note creates a named work stream, and git branch identifies it with an asterisk in the listing.
Why this matters

Short-lived branches separate unfinished work from the main line and provide clear boundaries for review, testing and eventual integration into shared history.

A common trap

Leaving unrelated uncommitted edits while switching branches can carry work into the wrong context; inspect status and commit coherent changes before switching.

Read all topics in this lesson

A complete reference to revisit alongside the guided steps above.

Branches and switching

A branch is a movable reference to a commit. Creating a branch does not duplicate every file; switching updates the working tree to match that branch. git switch -c creates and selects a branch. Commit or safely preserve edits before changing contexts. git switch -c feature-note creates a named work stream, and git branch identifies it with an asterisk in the listing. Short-lived branches separate unfinished work from the main line and provide clear boundaries for review, testing and eventual integration into shared history. Leaving unrelated uncommitted edits while switching branches can carry work into the wrong context; inspect status and commit coherent changes before switching.

WORKED EXAMPLE
git switch -c feature-note creates a named work stream, and git branch identifies it with an asterisk in the listing.

Why this matters

Short-lived branches separate unfinished work from the main line and provide clear boundaries for review, testing and eventual integration into shared history.

A common trap

Leaving unrelated uncommitted edits while switching branches can carry work into the wrong context; inspect status and commit coherent changes before switching.

Merging and conflicts

A merge combines changes from two histories. When both sides modify the same area incompatibly, Git pauses for a human decision. Conflict markers show candidate text; they are not final content. After resolving, stage the file and complete the merge or abort it. If main and feature both replace the same README line differently, git merge feature can stop with a conflict requiring a chosen result. Conflict resolution is a reasoning task about intended behavior; understanding it prevents blindly preserving broken combinations merely because Git accepts the final text. Committing conflict markers leaves invalid source or documentation behind; search for markers, inspect the intended result and run relevant checks before completing integration.

WORKED EXAMPLE
If main and feature both replace the same README line differently, git merge feature can stop with a conflict requiring a chosen result.

Why this matters

Conflict resolution is a reasoning task about intended behavior; understanding it prevents blindly preserving broken combinations merely because Git accepts the final text.

A common trap

Committing conflict markers leaves invalid source or documentation behind; search for markers, inspect the intended result and run relevant checks before completing integration.

Remotes and GitHub review

A remote is a named repository location, commonly origin. push sends commits and references; fetch downloads remote references; pull incorporates fetched changes according to configured behavior. GitHub pull requests add review, discussion and checks to a branch comparison, but do not replace Git commits. A typical hosted sequence is push a feature branch, open a pull request against main, review checks, then merge after required approval. Understanding local versus remote state avoids assuming an unpushed commit is visible to collaborators and makes publishing intentional rather than an accidental side effect. Force pushing shared history can disrupt collaborators; do not use it to solve an ordinary beginner synchronization problem without understanding whose commits would disappear.

WORKED EXAMPLE
A typical hosted sequence is push a feature branch, open a pull request against main, review checks, then merge after required approval.

Why this matters

Understanding local versus remote state avoids assuming an unpushed commit is visible to collaborators and makes publishing intentional rather than an accidental side effect.

A common trap

Force pushing shared history can disrupt collaborators; do not use it to solve an ordinary beginner synchronization problem without understanding whose commits would disappear.

KEEP THESE WITH YOU

Today’s takeaways

Branches name histories rather than copying projects.

Resolve conflicts according to intent.

A hosted pull request adds review to a Git branch comparison.

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