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 stash — Temporarily Saving Work

0m 00s

Putting Work on Hold

Stash saves your uncommitted changes to a temporary stack so you can switch branches or pull without losing your work:

git stash               # save all changes (tracked files)
git stash push -m "WIP: login form"   # save with a label

git stash list          # see all stashes
# stash@{0}: WIP: login form
# stash@{1}: On main: some old thing

git stash pop           # restore latest stash + remove from stack
git stash apply         # restore latest stash but KEEP it in stack
git stash apply stash@{1}  # restore a specific stash
git stash drop stash@{0}   # delete a specific stash
git stash clear         # delete all stashes

Common scenario

# Working on feature, urgent bug arrives
git stash
git switch hotfix-branch
# fix the bug, commit, push...
git switch feature-branch
git stash pop

Your Task

You've been editing work.txt but haven't committed. Stash your changes, make an "emergency" commit on a clean working tree, then pop the stash back.

Back
bashCtrl+Enter to run
Output

Click "Run" to execute your code.