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 rebase — Cleaner History

0m 00s

Replaying Commits on a New Base

Rebase moves your branch's commits so they appear to start from the tip of another branch — resulting in a linear history:

Before rebase:
  main:    A ─ B ─ C
  feature: A ─ D ─ E

After: git switch feature && git rebase main
  main:    A ─ B ─ C
  feature: A ─ B ─ C ─ D' ─ E'   (D, E replayed on top of C)
git switch feature
git rebase main          # rebase feature onto latest main

# If conflicts arise:
# 1. resolve the file
# git add resolved-file
# git rebase --continue  # continue
# git rebase --abort     # cancel and go back

merge vs rebase

  • merge — preserves full history, adds merge commit, non-destructive
  • rebase — creates linear history, rewrites commits, cleaner log

Golden rule: Never rebase public/shared branches — only your private feature branches.

Your Task

Main has moved ahead by one commit after you branched. Rebase feature onto the latest main.

Back
bashCtrl+Enter to run
Output

Click "Run" to execute your code.