Real-World Git Scenarios
Step-by-step guides for common Git situations you'll encounter in real projects. Each scenario includes interactive visualizations to help you understand what's happening.
Your First Git Commit
Turn a plain project folder into a repository: init, stage, commit, and keep going.
Cloning a Repository
Join an existing project: clone it from GitHub, explore it, and publish your first branch.
Undo the Last Commit
Amend, soft reset, hard reset, reflog recovery and revert β pick the right undo for each situation.
Feature Branch Workflow
The everyday team loop: branch, commit, push, keep up with main, merge and clean up.
Resolving a Merge Conflict
Two branches change the same lines. Read the conflict markers, resolve, and finish the merge.
Hotfix a Production Release
Patch a released version on its release branch, tag it, and carry the fix back to main with cherry-pick -x.
Rebase a PR onto the Latest Main
main moved and conflicts with your open pull request. Rebase, resolve, and update the PR with --force-with-lease.
Clean History Before Merging
Squash βfix typoβ commits and reword vague messages with interactive rebase, then fast-forward main.
Recover Lost Work
A branch deleted with -D, a reset that went too far β the reflog and ORIG_HEAD bring everything back.
Roll Back a Bad Merge
A merged feature broke production. Undo the whole merge on shared main with git revert -m 1.
Urgent Fix Mid-Feature
Park half-done work with git stash, ship an urgent fix on main, then pick up exactly where you left off.
Tag and Ship Versions
Mark every release with an annotated tag, push tags, and go back to any shipped version.
Split a Commit for Review
A reviewer asks for smaller commits. Undo the commit and re-stage it hunk by hunk with git add -p.
Clean Up Merged Branches
Prune branches deleted on GitHub, find which local branches are merged, and delete them safely.
Shallow Clones in CI
CI clones with --depth 1 for speed. See what a shallow history canβt do, then deepen or unshallow it.