A guide to the Git Fundamentals tutorial: creating and switching branches, inspecting changes with git diff and git show, and managing staging and undoing with git reset and git restore.
This tutorial covers the operations you use once the basic commit loop is second nature: working on branches, looking closely at changes, and managing or undoing what is staged. These make day-to-day Git productive and safe.
Branches: git branch and git checkout
git branch feature # create a branch
git checkout feature # switch to it
git checkout -b feature # create and switch in one step
A branch is an independent line of work. git branch creates one; git checkout switches to it. Working on a branch keeps main stable while you experiment.
Newer Git versions add git switch for changing branches and git switch -c to create one. checkout still does both and is what you practice here.
Inspecting changes: git diff and git show
git diff # unstaged changes
git diff --staged # staged changes
git show # the most recent commit in detail
git diff shows what you have changed but not yet staged; git diff --staged shows what is staged. git show displays a commit's full contents. These answer "what exactly changed?" before and after committing.
Managing staging and undoing: git restore and git reset
git restore index.html # discard uncommitted edits to a file
git restore --staged index.html # unstage a file (keep the edits)
git reset --soft HEAD~1 # undo the last commit, keep changes staged
git restore is the modern, focused tool for discarding working-file changes or unstaging. git reset moves the branch pointer and can unstage or undo commits.
git restore <file> permanently discards the uncommitted edits to that file. git restore --staged only unstages, keeping your edits. Know which one you are running before you run it.
Putting it together
A realistic flow: create a branch with git checkout -b, make changes, review them with git diff, stage and commit, and use git restore or git reset to fix mistakes. This is the everyday toolkit that the troubleshooting tutorials build on.