Git

Git Practice Exercises

Master Git from your first commit to advanced Git internals. Learn commits, branches, merging, rebasing, remotes, tags, history rewriting, recovery, hooks, and Git’s object model through hands-on problems. Every challenge is verified against a real repository, so you learn how Git actually works by using it, breaking it, and fixing it.

Git 2.47.3Git 2.47.3Linux CLILinux CLI
Read the Git overview
Module 1

Repositories & Commits

Initialize repositories, stage changes, and build a readable commit history.

4
About this challenge

Begin your Git journey by initializing a repo and performing your first commits.

About this challenge

Build a small project's history one commit at a time.

About this challenge

Read an existing project's history and answer questions about its commits.

About this challenge

Start a project from an empty folder and grow it into a readable history.

Module 2

Staging & Diffs

Control exactly what enters each commit and read every kind of diff.

4
About this challenge

Learn the difference between Git's two diffs by creating both at once.

About this challenge

Unstage a file without losing your work and commit only what you meant.

About this challenge

Inspect what past commits changed using diffs and summaries.

About this challenge

Untangle a messy working tree into a series of clean commits.

Module 3

Undoing Changes

Undo mistakes at every level with the right tool. Restore files, amend the last commit, and clean untracked debris safely.

4
About this challenge

Discard bad working tree edits and bring one file back from an older commit.

About this challenge

Fix the last commit's message and add its forgotten file without creating a new commit.

About this challenge

Preview and then safely delete untracked junk while every tracked edit survives.

About this challenge

Rescue a repository with one precise sequence of restores, an amend, and a safe clean.

Module 4

Branching

Keep separate lines of work on separate branches. Create, switch, rename, and delete branches, and rescue commits from a detached HEAD.

4
About this challenge

Give each feature its own branch from a shared base and keep their commits apart.

About this challenge

Rename, safely delete, and force delete branches according to what each one deserves.

About this challenge

Commit valuable work on a detached HEAD and rescue it onto a real branch.

About this challenge

Reorganize a repository's branches to an exact target topology, rescuing detached work first.

Module 5

Merging

Learn how to bring branches together with the history shape you intend. Fast forward when nothing diverged, record a true merge when both sides moved, and squash noisy work into one clean commit.

4
About this challenge

Integrate an ahead branch by fast-forward and see exactly when that stops being possible.

About this challenge

Join two diverged lines with a real merge commit, and force one even where fast-forward was possible.

About this challenge

Land a noisy feature branch as one clean commit while the branch itself stays intact.

About this challenge

Land three features with three different history shapes: fast forward, true merge, and squash.

Module 6

Remotes Basics

Learn how to work through a shared repository. Clone with tracking set up, fetch to observe before pulling to integrate, and publish and retire branches for the whole team.

4
About this challenge

Clone a shared repository and see the remote and tracking setup it configures for free.

About this challenge

See what fetch moves and what it does not, then integrate the fetched work with pull.

About this challenge

Push a new branch with its upstream in one step and delete a delivered branch from the shared repository.

About this challenge

Drive two clones and a shared repository through a full publish, relay, integrate, and retire cycle.

Module 7

Configuration & Ignoring

Configure Git, control ignored files, clean up tracked files, and speed up commands with aliases.

4
About this challenge

Set a machine-wide identity and a repository-local override, show where each value comes from, and prove which one commits use.

About this challenge

Ignore patterns, a whole directory and a negated exception inside it - then stop tracking an already-committed secrets file while keeping it on disk.

About this challenge

Define machine-wide aliases for the team's long commands, including one that takes its argument at the call site, and prove each reproduces its command.

About this challenge

Deliver the onboarding baseline: identity at the right levels, a complete ignore policy with a working exception, secrets untracked but kept, and the team's aliases.

Module 8

Merge Conflicts

Learn how to finish a merge that Git could not finish for you. Read the markers and combine both sides by hand, take a whole side when there is nothing to weave together, and abandon a botched attempt cleanly.

4
About this challenge

Start a merge that halts on conflicts, read the markers to combine both sides of two files by hand, and conclude the merge as a two-parent commit.

About this challenge

Begin a conflicting merge, abandon it mid-resolution, prove the repository came back to its exact pre-merge state, then redo the merge to the correct resolution.

About this challenge

Resolve a three-file merge conflict by taking whole sides - local for one file, incoming for another, a chosen side for a binary - and conclude the merge.

About this challenge

Abort a botched merge cleanly, then resolve four conflicting files - hand-combined, local side, incoming side and a binary - into one correct merge commit.

Module 9

Rebasing

Learn how to replay your work on top of someone else's instead of merging it in. Move a branch onto an advanced base, integrate a diverged clone without a merge commit, and transplant only the finished commits.

4
About this challenge

Replay a feature branch's commits onto an advanced main line, then catch the main line up without a merge commit, keeping history perfectly linear.

About this challenge

Integrate a diverged shared history by replaying local commits on top of the fetched tip instead of merging, then make that the default so the next plain pull stays merge-free too.

About this challenge

Replay only the fix commits from an unfinished feature branch onto the main tip, leaving the feature branch and its half-written work behind.

About this challenge

Bring a stranded feature, a pair of misparented fixes and a diverged clone into one straight line - replayed, transplanted and converged without a single merge commit.

Module 10

Interactive Rebase & History Editing

Learn how to rewrite a branch into the history a reviewer should see. Reorder and reword commits, squash noisy work into reviewable ones, and split a commit that does two things.

4
About this challenge

Interactively rebase a branch to replay its four commits in the right narrative order and fix two wrong commit messages, leaving every commit's content and the final tree untouched.

About this challenge

Collapse a trail of 'wip', 'typo' and 'oops' commits into three reviewable ones, letting two fixup-marked late fixes fold automatically into the different earlier commits they name, with the final tree unchanged.

About this challenge

Rewrite a branch so one commit that mixes a bug fix with a feature becomes two clean commits, the fix first, with everything stacked above it preserved.

About this challenge

Turn a working but unpresentable branch into the exact reviewable sequence - reordered, reworded, noise squashed, marked fixups folded into their targets and a bloated commit split - without changing what it builds.

About this path

This path starts with your first commit and goes on to staging, undoing changes, branching, merging, remotes, merge conflicts and interactive rebase. You work in a Linux terminal, so you should be comfortable running basic commands there. No earlier Git experience is needed. Later challenges have you clean up history before review by reordering, squashing and splitting commits.

Frequently asked questions

4

What will I practice in this path?

10 modules: Repositories & Commits, Staging & Diffs, Undoing Changes, Branching, Merging, Remotes Basics, Configuration & Ignoring, Merge Conflicts, Rebasing and Interactive Rebase & History Editing.

How many challenges are there, and how hard are they?

40 challenges: 28 easy and 12 medium.

What does this path run on?

Challenges run on Git 2.47.3 and Linux CLI.

Do I need to install anything?

No. Every challenge runs in a browser-based IDE with everything already set up, and your code is graded automatically against a test suite.

We use cookies that are necessary to run Staffcoder, and optional analytics cookies to see which pages get used. Analytics stays off unless you accept. Read our Cookie Policy.