Problems

#scenario-1-1
Fundamentals

Clone and Explore a Project

You've joined a new team. Your first task is to get the project code onto your machine from a remote repository and explore its current state.

#scenario-1-2
Fundamentals

Understanding Branch Structure and Switching

The project has multiple branches. You need to understand how to view them, switch between them, and understand what HEAD means.

#scenario-1-3
Fundamentals

Initializing a New Repository

You are starting a brand new project. The first step is to initialize a Git repository to start tracking your files.

#scenario-1-4
Fundamentals

Creating a Good Commit History

A clean, readable commit history is crucial for collaboration. Practice making small, logical, 'atomic' commits with clear messages.

#scenario-1-5
Fundamentals

Discard Changes and Restore Files

You made changes to several files but want to discard them. Learn safe ways to undo uncommitted work.

#scenario-2-1
Daily Operations

Temporarily Save Work with Git Stash

You're working on a feature when a critical bug needs immediate attention. Use stash to temporarily save your work so you can switch contexts.

#scenario-2-2
Daily Operations

Viewing Changes with Diff and Log

Learn to inspect your code changes and commit history effectively using git diff and git log.

#scenario-2-3
Daily Operations

Comparing Branches and Commits

Before merging or rebasing, you need to see what changes exist between branches. Learn to compare effectively.

#scenario-2-4
Daily Operations

Connect to Remote and Push Changes

Your local project is ready. Now it's time to connect it to a remote repository on a service like GitHub to back it up and collaborate with others.

#scenario-2-5
Daily Operations

Managing .gitignore Patterns

Learn to properly configure .gitignore to exclude files you don't want to track, and how to handle files that were accidentally committed.

#scenario-3-1
Branching & Collaboration

Branch Management Essentials

Master creating, switching, renaming, and deleting branches - the most frequent Git operations in daily development.

#scenario-3-2
Branching & Collaboration

Feature Branch Workflow

The standard workflow for developing a new feature is to create a dedicated branch. This keeps the 'main' branch clean and allows for code reviews before merging.

#scenario-3-3
Branching & Collaboration

Keep Your Branch Updated with Rebase

Your feature branch was created yesterday. Today, main has several new commits. Use rebase to build your feature on top of the latest main, keeping a clean linear history.

#scenario-3-4
Branching & Collaboration

Pull Remote Updates with Rebase

You have local commits on main, but a teammate pushed new commits to origin/main. Use git pull --rebase to avoid unnecessary merge commits.

#scenario-3-5
Branching & Collaboration

Resolving Merge Conflicts

You've been working on a feature, and in the meantime, someone else changed the same line of code on the 'main' branch. It's time to merge, and you need to resolve the conflict.

#scenario-4-1
Pull Requests & Code Review

Fork Workflow and Creating Pull Requests

You want to contribute to an open-source project. Learn the fork workflow: create your own copy, make changes, and submit a pull request.

#scenario-4-2
Pull Requests & Code Review

Squash Commits Before Pull Request

Your feature branch has messy commit history: 'WIP', 'fix typo', 'actually fix it'. Before submitting a PR, clean it up by squashing commits into one logical change.

#scenario-4-3
Pull Requests & Code Review

Code Review Workflow and Amending Commits

After pushing your feature branch, a reviewer requests changes. Learn to amend your commit and update the pull request.

#scenario-4-4
Pull Requests & Code Review

Advanced: Fixup Commits Workflow

For complex PRs with multiple commits, use fixup commits to address review feedback, then automatically squash them with autosquash rebase.

#scenario-5-1
Fixing Mistakes

Reset Explained: Soft, Mixed, and Hard

You've made a commit you want to undo locally. git reset is the tool, but it has three modes: soft, mixed, and hard. Understanding them is key to avoiding data loss.

#scenario-5-2
Fixing Mistakes

Reverting Pushed Commits Safely

You've pushed a commit to a shared branch that introduced a bug. You can't use git reset because it rewrites history. The safe way is with git revert.

#scenario-5-3
Fixing Mistakes

Recovery with Reflog

Disaster! You accidentally used git reset --hard and lost a commit. git reflog is your safety net, tracking all movements of HEAD, allowing you to recover.

Progress:0 / 22

Viewing Changes with Diff and Log

EasyDaily Operationsdiffloginspection

Description

Learn to inspect your code changes and commit history effectively using git diff and git log.

Theory Questions

1. What does 'git diff' show by default?

2. Which command shows you the commit history in a compact, one-line-per-commit format?

3. What does 'git diff --staged' show?