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 diff — Seeing What Changed

0m 00s

Comparing Versions

# What changed in working dir vs last commit (unstaged)?
git diff

# What's staged (ready to commit)?
git diff --staged

# Difference between two commits:
git diff abc123 def456

# Difference between two branches:
git diff main feature-branch

Reading a diff

-old line that was removed
+new line that was added
 unchanged context line

git show — inspect a specific commit

git show HEAD          # last commit
git show HEAD~1        # commit before last
git show abc1234       # specific commit by hash

HEAD — the current position

HEAD is a pointer to the commit you're currently working from — usually the tip of the branch you're on. HEAD~1 means "one commit before HEAD".

Your Task

A file has been committed. Modify it, then stage the change. The tests verify you have a staged diff ready to commit.

Back
bashCtrl+Enter to run
Output

Click "Run" to execute your code.