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 revert — Safely Undoing a Commit

0m 00s

The Safe Way to Undo (Especially on Shared Branches)

git revert creates a new commit that undoes a previous commit — it doesn't rewrite history. This makes it safe to use on shared/public branches where rewriting history would break others' repos.

git revert HEAD            # undo last commit (opens editor for message)
git revert HEAD --no-edit  # undo last commit, keep generated message
git revert abc1234         # undo a specific commit by hash
git revert HEAD~2..HEAD    # undo last 2 commits (creates 2 revert commits)

reset vs revert

git resetgit revert
Rewrites historyYesNo
Safe for shared branches❌ Never✅ Always
Creates new commitNoYes

Your Task

A bug was introduced in the last commit. Use git revert HEAD --no-edit to create a revert commit. The file should go back to its previous content.

Back
bashCtrl+Enter to run
Output

Click "Run" to execute your code.