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 commit --amend — Fixing the Last Commit

0m 00s

Correcting Mistakes Before They're Shared

--amend replaces the most recent commit with a new one. Use it to fix typos in commit messages or add forgotten files:

# Fix the commit message
git commit --amend -m "Correct message"

# Add a forgotten file to the last commit
git add forgotten.txt
git commit --amend --no-edit       # keep same message

# Both: add file + change message
git add forgotten.txt
git commit --amend -m "Better message with all files"

Rule: Only amend commits that haven't been pushed yet. Amending a pushed commit rewrites history and will confuse your teammates.

Your Task

The last commit has a typo in its message ("Aded" instead of "Added") and is missing styles.css. Fix both with --amend: the final message should be "Added homepage" and the commit must include both files.

Back
bashCtrl+Enter to run
Output

Click "Run" to execute your code.