Oops - How to Undo Anything
27%
Throw Away Changes You Don't Want
Let's say you're editing calculator.py and you accidentally break something. You haven't staged or committed the change yet - you just want to throw it away and go back to the last committed version.
First, let's simulate the mistake:
cat << 'EOF' > calculator.py
# calculator.py - A simple calculator
def add(a, b):
"""Add two numbers and return the result."""
return a + b + 999 # Oops! This is wrong
def subtract(a, b):
"""Subtract b from a and return the result."""
return a - b
# Try it out
result_add = add(5, 3)
result_sub = subtract(10, 4)
print(f"5 + 3 = {result_add}")
print(f"10 - 4 = {result_sub}")
EOF
Learn Git in a Day
Everything you need, nothing you don'tEnroll now to unlock all content and receive all future updates for free.
Unlock now $9.99$7.49Learn More
Hurry! This limited time offer ends in:
To redeem this offer, copy the coupon code below and apply it at checkout:
