noknow.dev
Sign inSign up
Course overview
Git — Complete Course
0 / 24 lessons0%

Git Basics

  • git init — Starting a Repository
  • git add + git commit — Your First Commit
  • git status + git log — Reading the State
  • git diff — Seeing What Changed
  • .gitignore — Ignoring Files

Branching

  • git branch + git switch — Working with Branches
  • git merge — Combining Branches
  • Resolving Merge Conflicts
  • Cleaning Up Branches

Remote Repositories

  • git remote — Connecting to a Remote
  • git push — Uploading Your Commits
  • git fetch + git pull — Getting Remote Changes
  • git clone — Copying a Repository

Undoing Changes

  • git restore — Discarding Uncommitted Changes
  • git reset — Moving HEAD Back
  • git revert — Safely Undoing a Commit
  • git stash — Temporarily Saving Work

Rewriting History

  • git commit --amend — Fixing the Last Commit
  • git rebase — Cleaner History
  • git cherry-pick — Applying Specific Commits

Advanced Tools and Workflows

  • git tag — Marking Releases
  • Mastering git log
  • git bisect — Finding Bugs with Binary Search
  • Professional Git Workflows

git restore — Discarding Uncommitted Changes

0m 00s

Throwing Away Unwanted Changes

git restore file.txt           # discard changes in working dir (like git checkout -- file)
git restore .                  # discard ALL working dir changes

git restore --staged file.txt  # unstage a file (keep changes in working dir)
git restore --staged .         # unstage everything

Warning: git restore on the working directory is permanent — the changes are gone, not just staged or committed. Only use it when you're sure.

The undo flow

git status                 # see what's changed
git diff                   # review the changes

# Option A: keep the changes (stage them)
git add file.txt

# Option B: throw them away
git restore file.txt

Your Task

important.txt has been accidentally overwritten. Use git restore to bring it back to its last committed state. Also, unstage draft.txt without deleting it.

Back
bashCtrl+Enter to run
Output

Click "Run" to execute your code.